NAG Library Function Document
nag_deviates_chi_sq (g01fcc) returns the deviate associated with the given lower tail probability of the -distribution with real degrees of freedom.
||nag_deviates_chi_sq (double p,
, associated with the lower tail probability
degrees of freedom is defined as the solution to
is found by using the relationship between a
-distribution and a gamma distribution, i.e., a
degrees of freedom is equal to a gamma distribution with scale parameter
and shape parameter
For very large values of
, greater than
, Wilson and Hilferty's normal approximation to the
is used; see Kendall and Stuart (1969)
Best D J and Roberts D E (1975) Algorithm AS 91. The percentage points of the distribution Appl. Statist. 24 385–388
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
p – doubleInput
On entry: , the lower tail probability from the required -distribution.
df – doubleInput
On entry: , the degrees of freedom of the -distribution.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
- On any of the error conditions listed below except NE_ALG_NOT_CONV nag_deviates_chi_sq (g01fcc) returns .
The algorithm has failed to converge in iterations.
The result should be a reasonable approximation.
The series used to calculate the gamma function has failed to converge.
This is an unlikely error exit.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
The probability is too close to or .
On entry, .
On entry, .
On entry, .
The results should be accurate to five significant digits for most argument values. Some accuracy is lost for close to .
For higher accuracy the relationship described in Section 3
may be used and a direct call to nag_deviates_gamma_dist (g01ffc)
This example reads lower tail probabilities for several -distributions, and calculates and prints the corresponding deviates until the end of data is reached.
9.1 Program Text
Program Text (g01fcce.c)
9.2 Program Data
Program Data (g01fcce.d)
9.3 Program Results
Program Results (g01fcce.r)