org.apache.mahout.math.jet.stat
Class Probability

java.lang.Object
  extended by org.apache.mahout.math.jet.stat.Probability

public final class Probability
extends Object

Partially deprecated until unit tests are in place. Until this time, this class/interface is unsupported.


Method Summary
static double beta(double a, double b, double x)
          Returns the area from zero to x under the beta density function.
static double gamma(double alpha, double beta, double x)
          Returns the integral from zero to x of the gamma probability density function.
static double negativeBinomial(int k, int n, double p)
          Returns the sum of the terms 0 through k of the Negative Binomial Distribution.
static double normal(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 normal(double mean, double variance, double x)
          Returns the area under the Normal (Gaussian) probability density function, integrated from minus infinity to x.
static double poisson(int k, double mean)
          Returns the sum of the first k terms of the Poisson distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

beta

public static double beta(double a,
                          double b,
                          double x)
Returns the area from zero to x under the beta density function.
                          x
            -             -
           | (a+b)       | |  a-1      b-1
 P(x)  =  ----------     |   t    (1-t)    dt
           -     -     | |
          | (a) | (b)   -
                         0
 
This function is identical to the incomplete beta integral function Gamma.incompleteBeta(a, b, x). The complemented function is 1 - P(1-x) = Gamma.incompleteBeta( b, a, x );


gamma

public static double gamma(double alpha,
                           double beta,
                           double x)
Returns the integral from zero to x of the gamma probability density function.

          alpha     - x
       beta        |     alpha-1  -beta t
 y =  ---------    |    t         e        dt
       -           |
      | (alpha)   -  0
 
The incomplete gamma integral is used, according to the relation y = Gamma.incompleteGamma( alpha, beta*x ). See http://en.wikipedia.org/wiki/Gamma_distribution#Probability_density_function

Parameters:
alpha - the shape parameter of the gamma distribution.
beta - the rate parameter of the gamma distribution.
x - integration end point.

negativeBinomial

public static double negativeBinomial(int k,
                                      int n,
                                      double p)
Returns the sum of the terms 0 through k of the Negative Binomial Distribution.
   k
   --  ( n+j-1 )   n      j
   >   (       )  p  (1-p)
   --  (   j   )
  j=0
 
In a sequence of Bernoulli trials, this is the probability that k or fewer failures precede the n-th success.

The terms are not computed individually; instead the incomplete beta integral is employed, according to the formula

y = negativeBinomial( k, n, p ) = Gamma.incompleteBeta( n, k+1, p ). All arguments must be positive,

Parameters:
k - end term.
n - the number of trials.
p - the probability of success (must be in (0.0,1.0)).

normal

public static double normal(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).
                            x
                             -
                   1        | |          2
  normal(x)  = ---------    |    exp( - t /2 ) dt
               sqrt(2pi)  | |
                           -
                          -inf.
 

= ( 1 + erf(z) ) / 2 = erfc(z) / 2

where z = x/sqrt(2). Computation is via the functions errorFunction and errorFunctionComplement.

Computed using method 26.2.17 from Abramovitz and Stegun (see http://www.math.sfu.ca/~cbm/aands/page_932.htm and http://en.wikipedia.org/wiki/Normal_distribution#Numerical_approximations_of_the_normal_cdf


normal

public static double normal(double mean,
                            double variance,
                            double x)
Returns the area under the Normal (Gaussian) probability density function, integrated from minus infinity to x.
                            x
                             -
                   1        | |                 2
  normal(x)  = ---------    |    exp( - (t-mean) / 2v ) dt
               sqrt(2pi*v)| |
                           -
                          -inf.

 
where v = variance. Computation is via the functions errorFunction.

Parameters:
mean - the mean of the normal distribution.
variance - the variance of the normal distribution.
x - the integration limit.

poisson

public static double poisson(int k,
                             double mean)
Returns the sum of the first k terms of the Poisson distribution.
   k         j
   --   -m  m
   >   e    --
   --       j!
  j=0
 
The terms are not summed directly; instead the incomplete gamma integral is employed, according to the relation

y = poisson( k, m ) = Gamma.incompleteGammaComplement( k+1, m ). The arguments must both be positive.

Parameters:
k - number of terms.
mean - the mean of the poisson distribution.


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.