public class Statistics extends java.lang.Object implements RevisionHandler
Constructor and Description |
---|
Statistics() |
Modifier and Type | Method and Description |
---|---|
static double |
binomialStandardError(double p,
int n)
Computes standard error for observed values of a binomial
random variable.
|
static double |
chiSquaredProbability(double x,
double v)
Returns chi-squared probability for given value and degrees
of freedom.
|
static double |
errorFunction(double x)
Returns the error function of the normal distribution.
|
static double |
errorFunctionComplemented(double a)
Returns the complementary Error function of the normal distribution.
|
static double |
FProbability(double F,
int df1,
int df2)
Computes probability of F-ratio.
|
static double |
gamma(double x)
Returns the Gamma function of the argument.
|
java.lang.String |
getRevision()
Returns the revision string.
|
static double |
incompleteBeta(double aa,
double bb,
double xx)
Returns the Incomplete Beta Function evaluated from zero to xx.
|
static double |
incompleteBetaFraction1(double a,
double b,
double x)
Continued fraction expansion #1 for incomplete beta integral.
|
static double |
incompleteBetaFraction2(double a,
double b,
double x)
Continued fraction expansion #2 for incomplete beta integral.
|
static double |
incompleteGamma(double a,
double x)
Returns the Incomplete Gamma function.
|
static double |
incompleteGammaComplement(double a,
double x)
Returns the Complemented Incomplete Gamma function.
|
static double |
lnGamma(double x)
Returns natural logarithm of gamma function.
|
static void |
main(java.lang.String[] ops)
Main method for testing this class.
|
static double |
normalInverse(double y0)
Returns the value, x, for which the area under the
Normal (Gaussian) probability density function (integrated from
minus infinity to x) is equal to the argument y
(assumes mean is zero, variance is one).
|
static double |
normalProbability(double a)
Returns the area under the Normal (Gaussian) probability density
function, integrated from minus infinity to x
(assumes mean is zero, variance is one).
|
static double |
p1evl(double x,
double[] coef,
int N)
Evaluates the given polynomial of degree N at x.
|
public static double binomialStandardError(double p, int n)
p
- the probability of successn
- the size of the samplepublic static double chiSquaredProbability(double x, double v)
x
- the valuev
- the number of degrees of freedompublic static double FProbability(double F, int df1, int df2)
F
- the F-ratiodf1
- the first number of degrees of freedomdf2
- the second number of degrees of freedompublic static double normalProbability(double a)
x - 1 | | 2 normal(x) = --------- | exp( - t /2 ) dt sqrt(2pi) | | - -inf. = ( 1 + erf(z) ) / 2 = erfc(z) / 2where z = x/sqrt(2). Computation is via the functions errorFunction and errorFunctionComplement.
a
- the z-valuepublic static double normalInverse(double y0)
For small arguments 0 < y < exp(-2), the program computes z = sqrt( -2.0 * log(y) ); then the approximation is x = z - log(z)/z - (1/z) P(1/z) / Q(1/z). There are two rational functions P/Q, one for 0 < y < exp(-32) and the other for y up to exp(-2). For larger arguments, w = y - 0.5, and x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)).
y0
- the area under the normal pdfpublic static double lnGamma(double x)
x
- the valuepublic static double errorFunction(double x)
x - 2 | | 2 erf(x) = -------- | exp( - t ) dt. sqrt(pi) | | - 0Implementation: For 0 <= |x| < 1, erf(x) = x * P4(x**2)/Q5(x**2); otherwise erf(x) = 1 - erfc(x).
Code adapted from the Java 2D Graph Package 2.4, which in turn is a port from the Cephes 2.2 Math Library (C).
a
- the argument to the function.public static double errorFunctionComplemented(double a)
1 - erf(x) = inf. - 2 | | 2 erfc(x) = -------- | exp( - t ) dt sqrt(pi) | | - xImplementation: For small x, erfc(x) = 1 - erf(x); otherwise rational approximations are computed.
Code adapted from the Java 2D Graph Package 2.4, which in turn is a port from the Cephes 2.2 Math Library (C).
a
- the argument to the function.public static double p1evl(double x, double[] coef, int N)
2 N y = C + C x + C x +...+ C x 0 1 2 N Coefficients are stored in reverse order: coef[0] = C , ..., coef[N] = C . N 0The function p1evl() assumes that coef[N] = 1.0 and is omitted from the array. Its calling arguments are otherwise the same as polevl().
In the interest of speed, there are no checks for out of bounds arithmetic.
x
- argument to the polynomial.coef
- the coefficients of the polynomial.N
- the degree of the polynomial.public static double incompleteGamma(double a, double x)
a
- the parameter of the gamma distribution.x
- the integration end point.public static double incompleteGammaComplement(double a, double x)
a
- the parameter of the gamma distribution.x
- the integration start point.public static double gamma(double x)
public static double incompleteBeta(double aa, double bb, double xx)
aa
- the alpha parameter of the beta distribution.bb
- the beta parameter of the beta distribution.xx
- the integration end point.public static double incompleteBetaFraction1(double a, double b, double x)
public static double incompleteBetaFraction2(double a, double b, double x)
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
public static void main(java.lang.String[] ops)