Click or drag to resize
RandomNextChiSquared Method
Generates a pseudorandom number from a Chi-squared distribution.

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
public virtual double NextChiSquared(
	double df
)

Parameters

df
Type: SystemDouble
A double which specifies the number of degrees of freedom. It must be positive.

Return Value

Type: Double
A double which specifies a pseudorandom number from a Chi-squared distribution.
Remarks

NextChiSquared generates pseudorandom numbers from a chi-squared distribution with df degrees of freedom. If df is an even integer less than 17, the chi-squared deviate r is generated as

r =  - 2\ln \left( {\mathop \Pi 
            \limits_{i = 1}^n } u_i \right)

where n = {\rm df}/2 and the u_i are independent random deviates from a uniform (0, 1) distribution. If df is an odd integer less than 17, the chi-squared deviate is generated in the same way, except the square of a normal deviate is added to the expression above. If df is greater than 16 or is not an integer, and if it is not too large to cause overflow in the gamma random number generator, the chi-squared deviate is generated as a special case of a gamma deviate, using NextGamma. If overflow would occur in NextGamma, the chi-squared deviate is generated in the manner described above, using the logarithm of the product of uniforms, but scaling the quantities to prevent underflow and overflow.

See Also