JMSLTM Numerical Library 3.0

com.imsl.stat
Class Cdf

java.lang.Object
  extended bycom.imsl.stat.Cdf

public final class Cdf
extends Object

Cumulative distribution functions.

See Also:
Example

Method Summary
static double beta(double x, double pin, double qin)
          Evaluates the beta probability distribution function.
static double binomial(int k, int n, double p)
          Evaluates the binomial distribution function.
static double binomialProb(int k, int n, double p)
          Evaluates the binomial probability function.
static double chi(double chsq, double df)
          Evaluates the chi-squared distribution function.
static double F(double x, double dfn, double dfd)
          Evaluates the F distribution function.
static double gamma(double x, double a)
          Evaluates the gamma distribution function.
static double hypergeometric(int k, int sampleSize, int defectivesInLot, int lotSize)
          Evaluates the hypergeometric distribution function.
static double hypergeometricProb(int k, int sampleSize, int defectivesInLot, int lotSize)
          Evaluates the hypergeometric probability function.
static double inverseBeta(double p, double pin, double qin)
          Evaluates the inverse of the beta probability distribution function.
static double inverseChi(double p, double df)
          Evaluates the inverse of the chi-squared distribution function.
static double inverseF(double p, double dfn, double dfd)
          Returns inverse of the F probability distribution function.
static double inverseGamma(double p, double a)
          Evaluates the inverse of the gamma distribution function.
static double inverseNormal(double p)
          Evaluates the inverse of the normal (Gaussian) distribution function.
static double inverseStudentsT(double p, double df)
          Returns inverse of the Student's t distribution function.
static double normal(double x)
          Evaluates the normal (Gaussian) distribution function.
static double poisson(int k, double theta)
          Evaluates the Poisson distribution function.
static double poissonProb(int k, double theta)
          Evaluates the Poisson probability function.
static double studentsT(double t, double df)
          Evaluates the Student's t distribution function.
static double Weibull(double x, double gamma, double alpha)
          Evaluates the Weibull distribution function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

binomial

public static double binomial(int k,
                              int n,
                              double p)
Evaluates the binomial distribution function.

Method binomial evaluates the distribution function of a binomial random variable with parameters n and p. It does this by summing probabilities of the random variable taking on the specific values in its range. These probabilities are computed by the recursive relationship

Pr left( {X = j} right) = 
  frac{{left( {n + 1 - j} right)p}}{{jleft( {1 - p} right)}}Pr 
  left( {X = j - 1} right)


To avoid the possibility of underflow, the probabilities are computed forward from 0, if k is not greater than n times p, and are computed backward from n, otherwise. The smallest positive machine number, varepsilon, is used as the starting value for summing the probabilities, which are rescaled by (1 - p)^nvarepsilon if forward computation is performed and by p^nvarepsilon if backward computation is done. For the special case of p = 0, binomial is set to 1; and for the case p = 1, binomial is set to 1 if k = n and to 0 otherwise.

Parameters:
k - the int argument for which the binomial distribution function is to be evaluated.
n - the int number of Bernoulli trials.
p - a double scalar value representing the probability of success on each trial.
Returns:
a double scalar value representing the probability that a binomial random variable takes a value less than or equal to k. This value is the probability that k or fewer successes occur in n independent Bernoulli trials, each of which has a p probability of success.
See Also:
Example

binomialProb

public static double binomialProb(int k,
                                  int n,
                                  double p)
Evaluates the binomial probability function.

Method binomialProb evaluates the probability that a binomial random variable with parameters n and p takes on the value k. It does this by computing probabilities of the random variable taking on the values in its range less than (or the values greater than) k. These probabilities are computed by the recursive relationship

Pr left( {X = j} right) = frac{{left( 
  {n + 1 - j} right)p}}{{jleft( {1 - p} right)}}Pr left( {X = j - 1} 
  right)


To avoid the possibility of underflow, the probabilities are computed forward from 0, if k is not greater than n times p, and are computed backward from n, otherwise. The smallest positive machine number, varepsilon, is used as the starting value for computing the probabilities, which are rescaled by (1 - p)^n varepsilon if forward computation is performed and by p^nvarepsilon if backward computation is done.

For the special case of p = 0, binomialProb is set to 0 if k is greater than 0 and to 1 otherwise; and for the case p = 1, binomialProb is set to 0 if k is less than n and to 1 otherwise.

Plot of Binomial Probability Function

Parameters:
k - the int argument for which the binomial distribution function is to be evaluated.
n - the int number of Bernoulli trials.
p - a double scalar value representing the probability of success on each trial.
Returns:
a double scalar value representing the probability that a binomial random variable takes a value equal to k.
See Also:
Example

poisson

public static double poisson(int k,
                             double theta)
Evaluates the Poisson distribution function.

poisson evaluates the distribution function of a Poisson random variable with parameter theta. theta, which is the mean of the Poisson random variable, must be positive. The probability function (with theta = theta) is

f(x) = e^{ - theta } theta ^x /x!,,, 
  for,x = 0,,1,,2,, ldots


The individual terms are calculated from the tails of the distribution to the mode of the distribution and summed. poisson uses the recursive relationship

fleft( {x + 1} right) = fleft( x right) 
  (theta /left( {x + 1} right)),,,,for,x = 0,,1,,2,, ldots 
  k-1


with f(0) = e^{-theta}.

Parameters:
k - the int argument for which the Poisson distribution function is to be evaluated.
theta - a double scalar value representing the mean of the Poisson distribution.
Returns:
a double scalar value representing the probability that a Poisson random variable takes a value less than or equal to k.
See Also:
Example

poissonProb

public static double poissonProb(int k,
                                 double theta)
Evaluates the Poisson probability function.

Method poissonProb evaluates the probability function of a Poisson random variable with parameter theta. theta, which is the mean of the Poisson random variable, must be positive. The probability function (with theta = theta) is

f(x) = e^{- theta} ,,theta ^k /k!,,,,,, 
  for,k = 0,,,1,,,2,, ldots


poissonProb evaluates this function directly, taking logarithms and using the log gamma function.

Poisson ProbabilityFunction

Parameters:
k - the int argument for which the Poisson probability function is to be evaluated.
theta - a double scalar value representing the mean of the Poisson distribution.
Returns:
a double scalar value representing the probability that a Poisson random variable takes a value equal to k.
See Also:
Example

beta

public static double beta(double x,
                          double pin,
                          double qin)
Evaluates the beta probability distribution function.

Method beta evaluates the distribution function of a beta random variable with parameters pin and qin. This function is sometimes called the incomplete beta ratio and, with p = pin and q = qin, is denoted by I_x(p, q). It is given by

I_x left( {p,,q} right) = frac{{Gamma 
  left( p right)Gamma left( q right)}}{{Gamma left( {p + q} 
  right)}}int_0^x {,t^{p - 1} left( {1 - t} right)^{q - 1} dt}


where Gamma(cdot) is the gamma function. The value of the distribution function I_x(p, q) is the probability that the random variable takes a value less than or equal to x.

The integral in the expression above is called the incomplete beta function and is denoted by beta_x (p, q). The constant in the expression is the reciprocal of the beta function (the incomplete function evaluated at one) and is denoted by beta_x (p, q).

beta uses the method of Bosten and Battiste (1974).

Plot of Beta Distribution Function

Parameters:
x - a double, the argument at which the function is to be evaluated.
pin - a double, the first beta distribution parameter.
qin - a double, the second beta distribution parameter.
Returns:
a double, the probability that a beta random variable takes on a value less than or equal to x.
See Also:
Example

inverseBeta

public static double inverseBeta(double p,
                                 double pin,
                                 double qin)
Evaluates the inverse of the beta probability distribution function.

Method inverseBeta evaluates the inverse distribution function of a beta random variable with parameters pin and qin, that is, with P = p, p = pin, and q = qin, it determines x (equal to inverseBeta (p, pin, qin)), such that

P = frac{{Gamma left( p right)Gamma 
  left( q right)}}{{Gamma left( {p + q} right)}}int_0^x {t^{p - 1} } 
  left( {1 - t} right)^{q - 1} dt


where Gamma(cdot) is the gamma function. The probability that the random variable takes a value less than or equal to x is P.

Parameters:
p - a double, the probability for which the inverse of the beta CDF is to be evaluated.
pin - a double, the first beta distribution parameter.
qin - a double, the second beta distribution parameter.
Returns:
a double, the probability that a beta random variable takes a value less than or equal to this value is p.
See Also:
Example

F

public static double F(double x,
                       double dfn,
                       double dfd)
Evaluates the F distribution function.

F evaluates the distribution function of a Snedecor's F random variable with dfn numerator degrees of freedom and dfd denominator degrees of freedom. The function is evaluated by making a transformation to a beta random variable and then using the function beta. If X is an F variate with v_1 and v_2 degrees of freedom and Y = v_1X/(v_2 + v_1X), then Y is a beta variate with parameters p = v_1/2 and q = v_2/2. F also uses a relationship between F random variables that can be expressed as follows:

{rm F}(X, {it dfn}, {it dfd})=1 - 
  {rm F}(1/X, {it dfd}, {it dfn})


Plot of F Distribution Function

Parameters:
x - a double, the argument at which the function is to be evaluated.
dfn - a double, the numerator degrees of freedom. It must be positive.
dfd - a double, the denominator degrees of freedom. It must be positive.
Returns:
a double, the probability that an F random variable takes on a value less than or equal to x.
See Also:
Example

inverseF

public static double inverseF(double p,
                              double dfn,
                              double dfd)
Returns inverse of the F probability distribution function.

Method inverseF evaluates the inverse distribution function of a Snedecor's F random variable with dfn numerator degrees of freedom and dfd denominator degrees of freedom. The function is evaluated by making a transformation to a beta random variable and then using inverseBeta. If X is an F variate with v_1 and v_2 degrees of freedom and Y = v_1X/(v_2 + v_1X), then Y is a beta variate with parameters p = v_1/2 and q = v_2/2. If P le 0.5, inverseF uses this relationship directly, otherwise, it also uses a relationship between X random variables that can be expressed as follows, using f, which is the F cumulative distribution function:

{rm F}(X, {it dfn}, {it dfd})=1 - 
  {rm F}(1/X, {it dfd}, {it dfn})


Parameters:
p - a double, the probability for which the inverse of the F distribution function is to be evaluated. Argument p must be in the open interval (0.0, 1.0).
dfn - a double, the numerator degrees of freedom. It must be positive.
dfd - a double, the denominator degrees of freedom. It must be positive.
Returns:
a double, the probability that an F random variable takes a value less than or equal to this value is p.
See Also:
Example

hypergeometricProb

public static double hypergeometricProb(int k,
                                        int sampleSize,
                                        int defectivesInLot,
                                        int lotSize)
Evaluates the hypergeometric probability function.

Method hypergeometricProb evaluates the probability function of a hypergeometric random variable with parameters n, l, and m. The hypergeometric random variable X can be thought of as the number of items of a given type in a random sample of size n that is drawn without replacement from a population of size l containing m items of this type. The probability function is:

{rm{Pr}}left( {X = k} right) = 
  frac{{left( {_k^m } right)left( {_{n - k}^{l - m} } right)}}{{left( 
  {_n^l } right)}}{rm{for}} ,,, k = i,;i + 1,,i + 2; ldots ,;min 
  left( {n,m} right)


where i = max(0, n - l + m). hypergeometricProb evaluates the expression using log gamma functions.

Parameters:
k - an int, the argument at which the function is to be evaluated.
sampleSize - an int, the sample size, n.
defectivesInLot - an int, the number of defectives in the lot, m.
lotSize - an int, the lot size, l.
Returns:
a double, the probability that a hypergeometric random variable takes on a value equal to k.
See Also:
Example

hypergeometric

public static double hypergeometric(int k,
                                    int sampleSize,
                                    int defectivesInLot,
                                    int lotSize)
Evaluates the hypergeometric distribution function.

Method hypergeometric evaluates the distribution function of a hypergeometric random variable with parameters n, l, and m. The hypergeometric random variable X can be thought of as the number of items of a given type in a random sample of size n that is drawn without replacement from a population of size l containing m items of this type. The probability function is

Pr left( {X = j} right) = frac{{left( 
  {_j^m } right)left( {_{n - j}^{l - m} } right)}}{{left( {_n^l } 
  right)}}{rm{for }},,j = i,;i + 1,,,i + 2,; ldots ,;min left( 
  {n,m} right)


where i = {rm max}(0, n - l + m).

If k is greater than or equal to i and less than or equal to min (n, m), hypergeometric sums the terms in this expression for j going from i up to k. Otherwise, hypergeometric returns 0 or 1, as appropriate. So, as to avoid rounding in the accumulation, hypergeometric performs the summation differently depending on whether or not k is greater than the mode of the distribution, which is the greatest integer less than or equal to (m + 1)(n + 1)/(l + 2).

Parameters:
k - an int, the argument at which the function is to be evaluated.
sampleSize - an int, the sample size, n.
defectivesInLot - an int, the number of defectives in the lot, m.
lotSize - an int, the lot size, l.
Returns:
a double, the probability that a hypergeometric random variable takes a value less than or equal to k.
See Also:
Example

gamma

public static double gamma(double x,
                           double a)
Evaluates the gamma distribution function.

Method gamma evaluates the distribution function, F, of a gamma random variable with shape parameter a; that is,

Fleft( x right) = frac{1}{{Gamma 
  left( a right)}}int_0^x {e^{ - t} t^{a - 1} } dt


where Gamma(cdot) is the gamma function. (The gamma function is the integral from 0 to infty of the same integrand as above). The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.

The gamma distribution is often defined as a two-parameter distribution with a scale parameter b (which must be positive), or even as a three-parameter distribution in which the third parameter c is a location parameter. In the most general case, the probability density function over (c, infty) is

fleft( t right) = frac{1}{{b^a Gamma 
  left( a right)}}e^{ - left( {t - c} right)/b} left( {x - c} 
  right)^{a - 1}


If T is such a random variable with parameters a, b, and c, the probability that T le t_0 can be obtained from gamma by setting X = (t_0 - c)/b.

If X is less than a or if X is less than or equal to 1.0, gamma uses a series expansion. Otherwise, a continued fraction expansion is used. (See Abramowitz and Stegun, 1964.)

Gamma Distribution Function

Parameters:
x - a double scalar value representing the argument at which the function is to be evaluated.
a - a double scalar value representing the shape parameter. This must be positive.
Returns:
a double scalar value representing the probability that a gamma random variable takes on a value less than or equal to x.
See Also:
Example

inverseGamma

public static double inverseGamma(double p,
                                  double a)
Evaluates the inverse of the gamma distribution function.

Method inverseGamma evaluates the inverse distribution function of a gamma random variable with shape parameter a, that is, it determines x ={rm inverseGamma} (p, a)), such that

P = frac{1}{{Gamma left( a right)}}int_o^x 
  {e^{ - t} } t^{a - 1} dt


where Gamma(cdot) is the gamma function. The probability that the random variable takes a value less than or equal to x is P. See the documentation for routine gamma for further discussion of the gamma distribution.

inverseGamma uses bisection and modified regula falsi to invert the distribution function, which is evaluated using method gamma.

Parameters:
p - a double scalar value representing the probability at which the function is to be evaluated.
a - a double scalar value representing the shape parameter. This must be positive.
Returns:
a double scalar value representing the probability that a gamma random variable takes a value less than or equal to this value is p.
See Also:
Example

normal

public static double normal(double x)
Evaluates the normal (Gaussian) distribution function.

Method normal evaluates the distribution function, Phi, of a standard normal (Gaussian) random variable, that is,

Phi left( x right) = frac{1}{{sqrt 
  {2pi } }}int_{ - infty }^x {} e^{ - t^2 /2} dt


The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.

The standard normal distribution (for which normal is the distribution function) has mean of 0 and variance of 1. The probability that a normal random variable with mean mu and variance sigma^2 is less than y is given by normal evaluated at (y - mu)/sigma.

Phi(x) is evaluated by use of the complementary error function, erfc. The relationship is:

Phi (x) = {rm{erfc}}( - x/ sqrt {2.0}) 
  /2


Standard Normal Distribution Function

Parameters:
x - a double scalar value representing the argument at which the function is to be evaluated.
Returns:
a double scalar value representing the probability that a normal variable takes a value less than or equal to x.
See Also:
Example

inverseNormal

public static double inverseNormal(double p)
Evaluates the inverse of the normal (Gaussian) distribution function.

Method inverseNormal evaluates the inverse of the distribution function, Phi, of a standard normal (Gaussian) random variable, that is, inverseNormal ({rm p})=Phi-1(p), where

Phi left( x right) = frac{1}{{sqrt 
  {2pi } }}int_{ - infty }^x {e^{ - t^2 /2} dt}


The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x. The standard normal distribution has a mean of 0 and a variance of 1.

Parameters:
p - a double scalar value representing the probability at which the function is to be evaluated.
Returns:
a double scalar value representing the probability that a standard normal random variable takes a value less than or equal to this value is p.
See Also:
Example

chi

public static double chi(double chsq,
                         double df)
Evaluates the chi-squared distribution function.

Method chi evaluates the distribution function, F, of a chi-squared random variable with df degrees of freedom, that is, with v = {rm df}, and x = {rm chsq},

Fleft( x right) = frac{1}{{2^{nu /2} 
  Gamma left( {nu /2} right)}} int_0^x {e^{ - t/2} t^{nu /2 - 1} } 
  dt


where Gamma (cdot) is the gamma function. The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.

For v gt 65, chi uses the Wilson-Hilferty approximation (Abramowitz and Stegun 1964, equation 26.4.17) to the normal distribution, and method normal is used to evaluate the normal distribution function.

For v le 65, chi uses series expansions to evaluate the distribution function. If x lt max (v/2, 26), chi uses the series 6.5.29 in Abramowitz and Stegun (1964), otherwise, it uses the asymptotic expansion 6.5.32 in Abramowitz and Stegun.

Plot of Chi-Squared Distribution Function

Parameters:
chsq - a double scalar value representing the argument at which the function is to be evaluated.
df - a double scalar value representing the number of degrees of freedom. This must be at least 0.5.
Returns:
a double scalar value representing the probability that a chi-squared random variable takes a value less than or equal to chsq.
See Also:
Example

inverseChi

public static double inverseChi(double p,
                                double df)
Evaluates the inverse of the chi-squared distribution function.

Method inverseChi evaluates the inverse distribution function of a chi-squared random variable with df degrees of freedom, that is, with P = p and v = df, it determines x (equal to inverseChi(p, df)), such that

P = frac{1}{{2^{nu /2} Gamma left( 
  {nu /2} right)}}int_0^x {e^{ - t/2} t^{nu /2 - 1} } dt


where Gamma(cdot) is the gamma function. The probability that the random variable takes a value less than or equal to x is P.

For v lt 40, inverseChi uses bisection, if v ge 2 or P gt 0.98, or regula falsi to find the point at which the chi-squared distribution function is equal to P. The distribution function is evaluated using chi.

For 40 le v lt 100, a modified Wilson-Hilferty approximation (Abramowitz and Stegun 1964, equation 26.4.18) to the normal distribution is used, and inverseNormal is used to evaluate the inverse of the normal distribution function. For v ge 100, the ordinary Wilson-Hilferty approximation (Abramowitz and Stegun 1964, equation 26.4.17) is used.

Parameters:
p - a double scalar value representing the probability for which the inverse chi-squared function is to be evaluated.
df - a double scalar value representing the number of degrees of freedom. This must be at least 0.5.
Returns:
a double scalar value representing the probability that a chi-squared random variable takes a value less than or equal to this value is p.
See Also:
Example

studentsT

public static double studentsT(double t,
                               double df)
Evaluates the Student's t distribution function.

Method studentsT evaluates the distribution function of a Student's t random variable with df degrees of freedom. If the square of t is greater than or equal to df, the relationship of a t to an f random variable (and subsequently, to a beta random variable) is exploited, and routine beta is used. Otherwise, the method described by Hill (1970) is used. If df is not an integer, if df is greater than 19, or if df is greater than 200, a Cornish-Fisher expansion is used to evaluate the distribution function. If df is less than 20 and left|{rm t}right| is less than 2.0, a trigonometric series (see Abramowitz and Stegun 1964, equations 26.7.3 and 26.7.4, with some rearrangement) is used. For the remaining cases, a series given by Hill (1970) that converges well for large values of t is used.

Student's t Distribution Function

Parameters:
t - a double scalar value representing the argument at which the function is to be evaluated
df - a double scalar value representing the number of degrees of freedom. This must be at least one.
Returns:
a double scalar value representing the probability that a Student's t random variable takes a value less than or equal to t
See Also:
Example

inverseStudentsT

public static double inverseStudentsT(double p,
                                      double df)
Returns inverse of the Student's t distribution function.

inverseStudentsT evaluates the inverse distribution function of a Student's t random variable with df degrees of freedom. Let v = df. If v equals 1 or 2, the inverse can be obtained in closed form, if v is between 1 and 2, the relationship of a t to a beta random variable is exploited and inverseBeta is used to evaluate the inverse; otherwise the algorithm of Hill (1970) is used. For small values of v greater than 2, Hill's algorithm inverts an integrated expansion in 1/(1 + t^2/v) of the t density. For larger values, an asymptotic inverse Cornish-Fisher type expansion about normal deviates is used.

Parameters:
p - a double scalar value representing the probability for which the inverse Student's t function is to be evaluated.
df - a double scalar value representing the number of degrees of freedom. This must be at least one.
Returns:
a double scalar value representing the probability that a Student's t random variable takes a value less than or equal to this value is p.
See Also:
Example

Weibull

public static double Weibull(double x,
                             double gamma,
                             double alpha)
Evaluates the Weibull distribution function.

Parameters:
x - a double scalar value representing the argument at which the function is to be evaluated. It must be non-negative.
gamma - a double scalar value representing the shape parameter.
alpha - a double scalar value representing the scale parameter.
Returns:
a double scalar value representing the probability that a Weibull random variable takes a value less than or equal to x

JMSLTM Numerical Library 3.0

Copyright 1970-2004 Visual Numerics, Inc.
Built November 5 2004.