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 ofChiSquareDistwith 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 inChiSquareDist.
-
-
Field Summary
-
Fields inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
decPrec
-
-
Constructor Summary
Constructors Constructor and Description ChiSquareDistQuick(int n)Constructs a chi-square distribution with n degrees of freedom.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubleinverseF(double u)Returns the inverse distribution function x = F-1(u).static doubleinverseF(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
-
Methods inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
getXinf, getXsup, inverseBisection, inverseBrent, setXinf, setXsup
-
-
-
-
Constructor Detail
-
ChiSquareDistQuick
public ChiSquareDistQuick(int n)
Constructs a chi-square distribution with n degrees of freedom.
-
-
Method Detail
-
inverseF
public double inverseF(double u)
Description copied from class:ContinuousDistributionReturns the inverse distribution function x = F-1(u). Restrictions: u∈[0, 1].- Specified by:
inverseFin interfaceDistribution- Overrides:
inverseFin classChiSquareDist- 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 inChiSquareDistfor 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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG