umontreal.iro.lecuyer.probdist
Class ChiSquareDistQuick
java.lang.Object
umontreal.iro.lecuyer.probdist.ContinuousDistribution
umontreal.iro.lecuyer.probdist.ChiSquareDist
umontreal.iro.lecuyer.probdist.ChiSquareDistQuick
- All Implemented Interfaces:
- Distribution
public class ChiSquareDistQuick
- extends ChiSquareDist
Provides a variant of ChiSquareDist
with
faster but less accurate methods.
The non-static version of
inverseF calls the static version.
This method is not very accurate for small n but becomes
better as n increases.
The other methods are the same as in ChiSquareDist
.
Constructor Summary |
ChiSquareDistQuick(int n)
Constructs a chi-square distribution with n degrees of freedom. |
Method Summary |
double |
inverseF(double u)
Returns the inverse distribution function
x = F-1(u). |
static double |
inverseF(int n,
double u)
Computes a quick-and-dirty approximation of F-1(u),
where F is the chi-square distribution with n degrees of freedom. |
Methods inherited from class umontreal.iro.lecuyer.probdist.ChiSquareDist |
barF, barF, cdf, cdf, density, density, getInstanceFromMLE, getMean, getMean, getMLE, getMomentsEstimate, getN, getParams, getStandardDeviation, getStandardDeviation, getVariance, getVariance, setN, toString |
ChiSquareDistQuick
public ChiSquareDistQuick(int n)
- Constructs a chi-square distribution with n degrees of freedom.
inverseF
public double inverseF(double u)
- Description copied from class:
ContinuousDistribution
- Returns the inverse distribution function
x = F-1(u).
Restrictions:
u∈[0, 1].
- Specified by:
inverseF
in interface Distribution
- Overrides:
inverseF
in class ChiSquareDist
- Parameters:
u
- value at which the inverse distribution function is evaluated
- Returns:
- the inverse distribution function evaluated at u
inverseF
public static double inverseF(int n,
double u)
- Computes a quick-and-dirty approximation of F-1(u),
where F is the chi-square distribution with n degrees of freedom.
Uses the approximation given in Figure L.24 of
Bratley, Fox and Schrage (1987) over most of the range.
For u < 0.02 or u > 0.98, it uses the approximation given in
Goldstein for n >= 10, and returns
2.0 *
GammaDist.inverseF
(n/2, 6, u)
for n < 10 in order to avoid
the loss of precision of the above approximations.
When n >= 10 or
0.02 < u < 0.98,
it is between 20 to 30 times faster than the same method in
ChiSquareDist
for n between 10 and 1000 and even faster
for larger n.
Note that the number d of decimal digits of precision
generally increases with n. For n = 3, we only have d = 3 over
most of the range. For n = 10, d = 5 except far in the tails where d = 3.
For n = 100, one has more than d = 7 over most of the range and for
n = 1000, at least d = 8.
The cases n = 1 and n = 2 are exceptions, with precision of about d = 10.
To submit a bug or ask questions, send an e-mail to
Pierre L'Ecuyer.