org.statcato.statistics
Class SpecialFunctions

java.lang.Object
  extended by org.statcato.statistics.SpecialFunctions

public class SpecialFunctions
extends java.lang.Object

A class of special functions that are used in calculating probability distributions. Based on Numerical Reciples in C: The Art of Scientific Computing (1992) http://www.nr.com

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
SpecialFunctions()
           
 
Method Summary
static double beta(double z, double w)
          Returns the beta function evaluated at (z,w).
static double betacf(double a, double b, double x)
          Used by betai: Evaluates continued fraction for incomplete beta function by modified Lentz's method.
static double betai(double a, double b, double x)
          Returns the incomplete beta function Ix(a, b).
static double binomialCoefficient(int n, int k)
          Returns the bionomial coefficient (n k) as a floating-point number.
static double cumBinomial(int n, int k, double p)
          Returns the cumulative binomial probability given n, k, and p, the probability of less than k successes occurring in n trials if a success occurs with probability p per trial
static double cumChiSquare(double chi2, double v1)
           
static double cumF(double F, double v1, double v2)
           
static double cumNorm(double z)
           
static double cumT(double t, double v1)
           
static double erff(double x)
          Returns the error function erf(x).
static double erffc(double x)
          Returns the complementary error function erfc(x).
static double factln(int n)
          Returns the natural logarithm of the factorial of a number: ln(n!).
static double factrl(int n)
          Returns the factorial of an integer.
static double gammln(double xx)
          Returns the value ln[ gamma(xx)] for xx > 0.
static double gammp(double a, double x)
          Returns the incomplete gamma function P(a, x).
static double gammq(double a, double x)
          Returns the incomplete gamm function Q(a, x) = 1 - P(a, x)
static void gcf(double a, double x)
          Computes the incomplete gamma function Q(a; x) evaluated by its continued fraction representation as gammcf.
static void gser(double a, double x)
          Computes the incomplete gamma function P(a, x) evaluated by its series representation and stores in global variable gamser.
static void nrerror(java.lang.String s)
           
static double sign(double a, double b)
          Returns the magnitude of a times the sign of b
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecialFunctions

public SpecialFunctions()
Method Detail

nrerror

public static void nrerror(java.lang.String s)

gammln

public static double gammln(double xx)
Returns the value ln[ gamma(xx)] for xx > 0.

Parameters:
xx - a number
Returns:
ln[gamma(xx)]

factrl

public static double factrl(int n)
Returns the factorial of an integer.

Parameters:
n -
Returns:
n! -1 indicates an error.

factln

public static double factln(int n)
Returns the natural logarithm of the factorial of a number: ln(n!).

Parameters:
n -
Returns:
ln(n!). -1 is returned for an error.

binomialCoefficient

public static double binomialCoefficient(int n,
                                         int k)
Returns the bionomial coefficient (n k) as a floating-point number.

Parameters:
n -
k -
Returns:
binomial coefficient

beta

public static double beta(double z,
                          double w)
Returns the beta function evaluated at (z,w).

Parameters:
z -
w -
Returns:
B(z,w)

gammp

public static double gammp(double a,
                           double x)
Returns the incomplete gamma function P(a, x).

Parameters:
a -
x -
Returns:
P(a, x)

gammq

public static double gammq(double a,
                           double x)
Returns the incomplete gamm function Q(a, x) = 1 - P(a, x)

Parameters:
a -
x -
Returns:
Q(a, x)

gser

public static void gser(double a,
                        double x)
Computes the incomplete gamma function P(a, x) evaluated by its series representation and stores in global variable gamser. Also computes ln _(a) and stores in global variable gln.

Parameters:
a -
x -

gcf

public static void gcf(double a,
                       double x)
Computes the incomplete gamma function Q(a; x) evaluated by its continued fraction representation as gammcf. Also computes ln _(a) as gln.

Parameters:
a -
x -

erff

public static double erff(double x)
Returns the error function erf(x).

Parameters:
x -
Returns:
erf(x)

erffc

public static double erffc(double x)
Returns the complementary error function erfc(x).

Parameters:
x -
Returns:
erffc(x)

betai

public static double betai(double a,
                           double b,
                           double x)
Returns the incomplete beta function Ix(a, b).

Parameters:
a -
b -
x -
Returns:
incomplete beta function value

betacf

public static double betacf(double a,
                            double b,
                            double x)
Used by betai: Evaluates continued fraction for incomplete beta function by modified Lentz's method.

Parameters:
a -
b -
x -
Returns:
betacf

cumT

public static double cumT(double t,
                          double v1)

cumF

public static double cumF(double F,
                          double v1,
                          double v2)

cumNorm

public static double cumNorm(double z)

cumChiSquare

public static double cumChiSquare(double chi2,
                                  double v1)

cumBinomial

public static double cumBinomial(int n,
                                 int k,
                                 double p)
Returns the cumulative binomial probability given n, k, and p, the probability of less than k successes occurring in n trials if a success occurs with probability p per trial

Parameters:
n - the number of trials
k - the number of successes
p - the probability of success
Returns:
P(n, k, p)

sign

public static double sign(double a,
                          double b)
Returns the magnitude of a times the sign of b

Parameters:
a -
b -
Returns:
the magnitude of a times the sign of b