# naginterfaces.library.stat.inv_​cdf_​gamma_​vector¶

naginterfaces.library.stat.inv_cdf_gamma_vector(tail, p, a, b, tol=0.0)[source]

inv_cdf_gamma_vector returns a number of deviates associated with given probabilities of the gamma distribution.

For full information please refer to the NAG Library document for g01tf

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/g01/g01tff.html

Parameters
tailstr, length 1, array-like, shape

Indicates which tail the supplied probabilities represent. For , for :

The lower tail probability, i.e., .

The upper tail probability, i.e., .

pfloat, array-like, shape

, the probability of the required gamma distribution as defined by .

afloat, array-like, shape

, the first parameter of the required gamma distribution.

bfloat, array-like, shape

, the second parameter of the required gamma distribution.

tolfloat, optional

The relative accuracy required by you in the results. If inv_cdf_gamma_vector is entered with greater than or equal to or less than (see machine.precision), the value of is used instead.

Returns
gfloat, ndarray, shape

, the deviates for the gamma distribution.

ivalidint, ndarray, shape

indicates any errors with the input arguments, with

No error.

On entry, invalid value supplied in when calculating .

On entry, invalid value for .

On entry, , or, , or, .

is too close to or to enable the result to be calculated.

The solution has failed to converge. The result may be a reasonable approximation.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

On entry, at least one value of , , , or was invalid.

Notes

The deviate, , associated with the lower tail probability, , of the gamma distribution with shape parameter and scale parameter , is defined as the solution to

The method used is described by Best and Roberts (1975) making use of the relationship between the gamma distribution and the -distribution.

Let . The required is found from the Taylor series expansion

where is a starting approximation

,

,

,

,

.

For most values of and the starting value

is used, where is the deviate associated with a lower tail probability of for the standard Normal distribution.

For close to zero,

is used.

For large values, when ,

is found to be a better starting value than .

For small , is expressed in terms of an approximation to the exponential integral and is found by Newton–Raphson iterations.

Seven terms of the Taylor series are used to refine the starting approximation, repeating the process if necessary until the required accuracy is obtained.

The input arrays to this function are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See the G01 Introduction for further information.

References

Best, D J and Roberts, D E, 1975, Algorithm AS 91. The percentage points of the distribution, Appl. Statist. (24), 385–388