IMSL C# Numerical Library

Random.NextBeta Method 

Generate a pseudorandom number from a beta distribution.

public virtual double NextBeta(
   double p,
   double q
);

Parameters

p
A double which specifies the first beta distribution parameter, p \gt 0.
q
A double which specifies the second beta distribution parameter, q \gt 0.

Return Value

A double which specifies a pseudorandom number from a beta distribution.

Remarks

Method NextBeta generates pseudorandom numbers from a beta distribution with parameters p and q, both of which must be positive. The probability density function is

f\left( x \right) = \frac{{\Gamma \left( 
            {p + q} \right)}}{{\Gamma \left( p \right)\Gamma \left( q 
            \right)}}x^{p - 1} \left( {1 - x} \right)^{q - 1\,\,\,\,} \,\, 
            for\,0 \le x \le 1

where \Gamma (\cdot) is the gamma function.

The algorithm used depends on the values of p and q. Except for the trivial cases of p = 1 or q = 1, in which the inverse CDF method is used, all of the methods use acceptance/rejection. If p and q are both less than 1, the method of Johnk (1964) is used; if either p or q is less than 1 and the other is greater than 1, the method of Atkinson (1979) is used; if both p and q are greater than 1, algorithm BB of Cheng (1978), which requires very little setup time, is used.

The value returned is less than 1.0 and greater than \varepsilon, where \varepsilon is the smallest positive number such that 1.0 - \varepsilon is less than 1.0.

See Also

Random Class | Imsl.Stat Namespace | Example