|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.Statistics
Class implementing some distributions, tests, etc. The code is mostly adapted from the CERN Jet Java libraries: Copyright © 2001 University of Waikato Copyright © 1999 CERN - European Organization for Nuclear Research. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. CERN and the University of Waikato make no representations about the suitability of this software for any purpose. It is provided "as is" without expressed or implied warranty.
Field Summary | |
protected static double |
big
|
protected static double |
biginv
|
protected static double |
LOGPI
|
protected static double |
MACHEP
Some constants |
protected static double |
MAXGAM
|
protected static double |
MAXLOG
|
protected static double |
MINLOG
|
protected static double[] |
P0
COEFFICIENTS FOR METHOD normalInverse() * |
protected static double[] |
P1
|
protected static double[] |
P2
|
protected static double[] |
Q0
|
protected static double[] |
Q1
|
protected static double[] |
Q2
|
protected static double |
SQRTH
|
protected static double |
SQTPI
|
Constructor Summary | |
Statistics()
|
Method Summary | |
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. |
(package private) static double |
errorFunction(double x)
Returns the error function of the normal distribution. |
(package private) 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. |
(package private) static double |
gamma(double x)
Returns the Gamma function of the argument. |
static double |
incompleteBeta(double aa,
double bb,
double xx)
Returns the Incomplete Beta Function evaluated from zero to xx. |
(package private) static double |
incompleteBetaFraction1(double a,
double b,
double x)
Continued fraction expansion #1 for incomplete beta integral. |
(package private) static double |
incompleteBetaFraction2(double a,
double b,
double x)
Continued fraction expansion #2 for incomplete beta integral. |
(package private) static double |
incompleteGamma(double a,
double x)
Returns the Incomplete Gamma function. |
(package private) 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). |
(package private) static double |
p1evl(double x,
double[] coef,
int N)
Evaluates the given polynomial of degree N at x. |
(package private) static double |
polevl(double x,
double[] coef,
int N)
Evaluates the given polynomial of degree N at x. |
(package private) static double |
powerSeries(double a,
double b,
double x)
Power series for incomplete beta integral. |
(package private) static double |
stirlingFormula(double x)
Returns the Gamma function computed by Stirling's formula. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final double MACHEP
protected static final double MAXLOG
protected static final double MINLOG
protected static final double MAXGAM
protected static final double SQTPI
protected static final double SQRTH
protected static final double LOGPI
protected static final double big
protected static final double biginv
protected static final double[] P0
protected static final double[] Q0
protected static final double[] P1
protected static final double[] Q1
protected static final double[] P2
protected static final double[] Q2
Constructor Detail |
public Statistics()
Method Detail |
public static double binomialStandardError(double p, int n)
p
- the probability of successn
- the size of the sample
public static double chiSquaredProbability(double x, double v)
x
- the value
public 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 freedom
public 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-value
public 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 pdf
public static double lnGamma(double x)
x
- the value
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).
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.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.static double polevl(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 0In 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.static double incompleteGamma(double a, double x)
a
- the parameter of the gamma distribution.x
- the integration end point.static double incompleteGammaComplement(double a, double x)
a
- the parameter of the gamma distribution.x
- the integration start point.static double gamma(double x)
static double stirlingFormula(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.static double incompleteBetaFraction1(double a, double b, double x)
static double incompleteBetaFraction2(double a, double b, double x)
static double powerSeries(double a, double b, double x)
public static void main(java.lang.String[] ops)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |