gammaCdf

Evaluates the gamma distribution function.

Synopsis

gammaCdf (x, a)

Required Arguments

float x (Input)
Argument for which the gamma distribution function is to be evaluated.
float a (Input)
The shape parameter of the gamma distribution. This parameter must be positive.

Return Value

The probability that a gamma random variable takes a value less than or equal to x.

Description

The function gammaCdf evaluates the distribution function, F, of a gamma random variable with shape parameter a, that is,

F(x)=1Γ(a)x0etta1dt

where Γ(⋅) is the gamma function. (The gamma function is the integral from zero to infinity of the same integrand as above). The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.

The gamma distribution is often defined as a two-parameter distribution with a scale parameter b (which must be positive) or even as a three-parameter distribution in which the third parameter c is a location parameter.

In the most general case, the probability density function over (c, ∞) is

f(t)=1baΓ(a)e(tc)/b(xc)a1

If T is such a random variable with parameters a, b, and c, the probability that Tt0 can be obtained from gammaCdf by setting x=(t0c)/b.

If x is less than a or if x is less than or equal to 1.0, gammaCdf uses a series expansion. Otherwise, a continued fraction expansion is used. (See Abramowitz and Stegun 1964.)

Example

Let X be a gamma random variable with a shape parameter of four. (In this case, it has an Erlang distribution since the shape parameter is an integer.) This example finds the probability that X is less than 0.5 and the probability that X is between 0.5 and 1.0.

from __future__ import print_function
from numpy import *
from pyimsl.math.gammaCdf import gammaCdf

a = 4.0
x = 0.5
p = gammaCdf(x, a)
print("The probability that X is less than 0.5 is %6.4f" % (p))

x = 1.0
p = gammaCdf(x, a) - p
print("The probability that X is between 0.5 and 1.0 is %6.4f" % (p))

Output

The probability that X is less than 0.5 is 0.0018
The probability that X is between 0.5 and 1.0 is 0.0172

Informational Errors

IMSL_LESS_THAN_ZERO The input argument, x, is less than zero.

Fatal Errors

IMSL_X_AND_A_TOO_LARGE The function overflows because x and a are too large.