C# Class Accord.Math.Normal

Normal distribution functions.
References: Cephes Math Library, http://www.netlib.org/cephes/ George Marsaglia, Evaluating the Normal Distribution, 2004. Available in: http://www.jstatsoft.org/v11/a05/paper
ファイルを表示 Open project: accord-net/framework Class Usage Examples

Public Methods

Method Description
Bivariate ( double x, double y, double rho ) : double

Bivariate normal cumulative distribution function.

BivariateComplemented ( double x, double y, double rho ) : double

Complemented bivariate normal cumulative distribution function.

Complemented ( double value ) : double

Complemented cumulative distribution function.

Derivative ( double value ) : double

First derivative of Normal cumulative distribution function, also known as the Normal density function.

Function ( double value ) : double

Normal cumulative distribution function.

Gaussian ( double sigmaSquared, double x ) : double

1-D Gaussian function.

The function calculates 1-D Gaussian function:

f(x) = exp( x * x / ( -2 * s * s ) ) / ( s * sqrt( 2 * PI ) )
Gaussian2D ( double sigmaSquared, double x, double y ) : double

2-D Gaussian function.

The function calculates 2-D Gaussian function:

f(x, y) = exp( x * x + y * y / ( -2 * s * s ) ) / ( s * s * 2 * PI )
HighAccuracyComplemented ( double x ) : double

High-accuracy Complementary normal distribution function.

This function uses 9 tabled values to provide tail values of the normal distribution, also known as complementary Phi, with an absolute error of 1e-14 ~ 1e-16.

References: - George Marsaglia, Evaluating the Normal Distribution, 2004. Available in: http://www.jstatsoft.org/v11/a05/paper
HighAccuracyFunction ( double x ) : double

High-accuracy Normal cumulative distribution function.

The following formula provide probabilities with an absolute error less than 8e-16.

References: - George Marsaglia, Evaluating the Normal Distribution, 2004. Available in: http://www.jstatsoft.org/v11/a05/paper

Inverse ( double y0 ) : double

Normal (Gaussian) inverse cumulative distribution function.

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)).

Kernel ( double sigmaSquared, int size ) : double[]

1-D Gaussian kernel.

The function calculates 1-D Gaussian kernel, which is array of Gaussian function's values in the [-r, r] range of x value, where r=floor(size/2).

Kernel2D ( double sigmaSquared, int size ) : ].double[

2-D Gaussian kernel.

The function calculates 2-D Gaussian kernel, which is array of Gaussian function's values in the [-r, r] range of x,y values, where r=floor(size/2).

Log ( double value ) : double

Normal cumulative distribution function.

LogDerivative ( double value ) : double

Log of the first derivative of Normal cumulative distribution function, also known as the Normal density function.

Private Methods

Method Description
BVND ( double dh, double dk, double r ) : double

A function for computing bivariate normal probabilities. BVND calculates the probability that X > DH and Y > DK.

This method is based on the work done by Alan Genz, Department of Mathematics, Washington State University. Pullman, WA 99164-3113 Email: [email protected]. This work was shared under a 3-clause BSD license. Please see source file for more details and the actual license text.

This function is based on the method described by Drezner, Z and G.O. Wesolowsky, (1989), On the computation of the bivariate normal integral, Journal of Statist. Comput. Simul. 35, pp. 101-107, with major modifications for double precision, and for |R| close to 1.

Method Details

Bivariate() public static method

Bivariate normal cumulative distribution function.
public static Bivariate ( double x, double y, double rho ) : double
x double The value of the first variate.
y double The value of the second variate.
rho double The correlation coefficient between x and y. This can be computed /// from a covariance matrix C as rho = C_12 / (sqrt(C_11) * sqrt(C_22)).
return double

BivariateComplemented() public static method

Complemented bivariate normal cumulative distribution function.
public static BivariateComplemented ( double x, double y, double rho ) : double
x double The value of the first variate.
y double The value of the second variate.
rho double The correlation coefficient between x and y. This can be computed /// from a covariance matrix C as rho = C_12 / (sqrt(C_11) * sqrt(C_22)).
return double

Complemented() public static method

Complemented cumulative distribution function.
public static Complemented ( double value ) : double
value double
return double

Derivative() public static method

First derivative of Normal cumulative distribution function, also known as the Normal density function.
public static Derivative ( double value ) : double
value double
return double

Function() public static method

Normal cumulative distribution function.
public static Function ( double value ) : double
value double
return double

Gaussian() public static method

1-D Gaussian function.

The function calculates 1-D Gaussian function:

f(x) = exp( x * x / ( -2 * s * s ) ) / ( s * sqrt( 2 * PI ) )
public static Gaussian ( double sigmaSquared, double x ) : double
sigmaSquared double The variance parameter σ² (sigma squared).
x double x value.
return double

Gaussian2D() public static method

2-D Gaussian function.

The function calculates 2-D Gaussian function:

f(x, y) = exp( x * x + y * y / ( -2 * s * s ) ) / ( s * s * 2 * PI )
public static Gaussian2D ( double sigmaSquared, double x, double y ) : double
sigmaSquared double The variance parameter σ² (sigma squared).
x double x value.
y double y value.
return double

HighAccuracyComplemented() public static method

High-accuracy Complementary normal distribution function.

This function uses 9 tabled values to provide tail values of the normal distribution, also known as complementary Phi, with an absolute error of 1e-14 ~ 1e-16.

References: - George Marsaglia, Evaluating the Normal Distribution, 2004. Available in: http://www.jstatsoft.org/v11/a05/paper
public static HighAccuracyComplemented ( double x ) : double
x double
return double

HighAccuracyFunction() public static method

High-accuracy Normal cumulative distribution function.

The following formula provide probabilities with an absolute error less than 8e-16.

References: - George Marsaglia, Evaluating the Normal Distribution, 2004. Available in: http://www.jstatsoft.org/v11/a05/paper

public static HighAccuracyFunction ( double x ) : double
x double
return double

Inverse() public static method

Normal (Gaussian) inverse cumulative distribution function.

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)).

public static Inverse ( double y0 ) : double
y0 double
return double

Kernel() public static method

1-D Gaussian kernel.

The function calculates 1-D Gaussian kernel, which is array of Gaussian function's values in the [-r, r] range of x value, where r=floor(size/2).

Wrong kernel size.
public static Kernel ( double sigmaSquared, int size ) : double[]
sigmaSquared double The variance parameter σ² (sigma squared).
size int Kernel size (should be odd), [3, 101].
return double[]

Kernel2D() public static method

2-D Gaussian kernel.

The function calculates 2-D Gaussian kernel, which is array of Gaussian function's values in the [-r, r] range of x,y values, where r=floor(size/2).

Wrong kernel size.
public static Kernel2D ( double sigmaSquared, int size ) : ].double[
sigmaSquared double The variance parameter σ² (sigma squared).
size int Kernel size (should be odd), [3, 101].
return ].double[

Log() public static method

Normal cumulative distribution function.
public static Log ( double value ) : double
value double
return double

LogDerivative() public static method

Log of the first derivative of Normal cumulative distribution function, also known as the Normal density function.
public static LogDerivative ( double value ) : double
value double
return double