FastRangeRatioDistribution
Package: Libraries.Compute.Statistics.Distributions · Inherits from: Libraries.Language.Object, Libraries.Compute.Statistics.Distributions.NumberDistribution
The FastRangeRatioDistribution class is the distribution of the studentized range (the range of k group means divided by an estimate of their standard deviation on f degrees of freedom), which Tukey's test uses. It computes the same distribution as RangeRatioDistribution with a faster, less accurate algorithm, and is kept for when speed matters more than the last few decimal places, such as simulations. It implements Algorithm AS 190: R. E. Lund and J. R. Lund (1983), "Algorithm AS 190: Probabilities and Upper Quantiles for the Studentized Range", Applied Statistics 32(2), 204-210, adapted from the published FORTRAN. The cumulative distribution sums a trapezoidal rule over a fixed grid and stops once terms fall below fixed cutoffs; the inverse uses the secant method from an initial estimate built on AS 190.2, AS 70 (R. E. Odeh and J. O. Evans (1974), "Algorithm AS 70: The Percentage Points of the Normal Distribution", Applied Statistics 23, 96-97) and AS 111. Lund and Lund give a maximum error of about 0.0005. Compared with RangeRatioDistribution (Copenhaver and Holland, 1988), which agrees with R's ptukey and SciPy to about 1e-11: - cumulative values are about 1e-4 low (0.94400 for 0.94411 with q = 3.5, 3 means and 20 degrees of freedom; 0.949874 where the exact answer is 0.95, with 2 means), which makes small Tukey p-values much too large in relative terms (0.000596 for R's 0.000459); - inverses are 0.002 to 0.005 high (3.5796 for 3.5779); - it is about 25 to 100 times faster: 0.09 to 0.22 milliseconds for a cumulative value against 6 to 10, and about 1 millisecond for an inverse against 50 to 60. The difference comes from the early stopping: with its cutoffs made tiny, the same grid agrees with R to 1.5e-8. More information: https://en.wikipedia.org/wiki/Studentized_range_distribution
Example Code
use Libraries.Compute.Statistics.Distributions.FastRangeRatioDistribution
FastRangeRatioDistribution distribution
distribution:Setup(3, 20)
output distribution:CumulativeDistribution(3.5)
Actions
CumulativeDistribution(number q)
It is a Quorum implmentation of the Fortran code from Applied Statistics Evaluates the probability from 0 to q for a studentized range having v degrees of freedom and r samples. See Algorithm AS 190 - 1985 Edition http://bayanbox.ir/view/3820206914900746365/StatLab-Applied-Statistics-Algorithms.pdf
Parameters
qnumber
Returns
number
GetDegreesOfFreedom()
This action is a Quorum implmentation of the Fortran code from Applied Statistics Approximates the quantile p for a studentized range distribution having v degrees of freedom and r samples for probability p. See Algorithm AS 190.1 - 1985 Edition http://bayanbox.ir/view/3820206914900746365/StatLab-Applied-Statistics-Algorithms.pdf ALSO See Secant Method https://en.wikipedia.org/wiki/Secant_method The result from this action is within about 0.005 of the true value (0.002 to 0.005 high in the cases checked against R), since the cumulative distribution it inverts is about 1e-4 low.
Returns
number
GetLowerBound()
Returns
number
GetMean()
Returns
number
GetNumberOfMeans()
Compute integral
Returns
number
GetSolverAbsoluteAccuracy()
Returns
number
GetSupportLowerBound()
Compute constants, local midpoint, adjust steps
Returns
number
GetSupportUpperBound()
It is a Quorum implmentation of the Fortran code from Applied Statistics Evaluates the probability from 0 to q for a studentized range having v degrees of freedom and r samples. See Algorithm AS 190 - 1985 Edition http://bayanbox.ir/view/3820206914900746365/StatLab-Applied-Statistics-Algorithms.pdf
Returns
number
GetUpperBound()
Returns
number
GetVariance()
Returns
number
InverseCumulativeDistribution(number p)
This action is a Quorum implmentation of the Fortran code from Applied Statistics Approximates the quantile p for a studentized range distribution having v degrees of freedom and r samples for probability p. See Algorithm AS 190.1 - 1985 Edition http://bayanbox.ir/view/3820206914900746365/StatLab-Applied-Statistics-Algorithms.pdf ALSO See Secant Method https://en.wikipedia.org/wiki/Secant_method The result from this action is within about 0.005 of the true value (0.002 to 0.005 high in the cases checked against R), since the cumulative distribution it inverts is about 1e-4 low.
Parameters
pnumber
Returns
number
IsSupportConnected()
Returns
boolean
IsSupportLowerBoundInclusive()
Returns
boolean
IsSupportUpperBoundInclusive()
Returns
boolean
Setup(number numberOfMeans, number degreesOfFreedom)
Parameters
numberOfMeansnumberdegreesOfFreedomnumber