com.singularsys.extensions.statistical.distributions

## Class NormalDist

• All Implemented Interfaces:
PostfixMathCommandI, java.io.Serializable

```public class NormalDist
extends NaryFunction```
The normal distribution function.

Works like Excel's NORMDIST function `normdist(X,mu,sd)` calculates the cumulative probability p(x < X) with mean mu and standard deviation sd. A four argument form `normdist(x,mu,sd,0)` gives the pdf.

The algorithm for the cdf has come from George Marsaglia Evaluating the Normal Distribution Journal of Statistical Software, Vol 11, issue 4, 2004, https://www.jstatsoft.org/article/view/v011i04

It is accurate to about 1e15 or 1e16. For greater accuracy try the Apache Common Math Library http://commons.apache.org/proper/commons-math/.

Author:
rich
Serialized Form
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `NormalDist.Type`
Type of dictributuion to calculate PDF/CDF

• ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

`curNumberOfParameters, name, NaN, numberOfParameters`
• ### Constructor Summary

Constructors
Constructor and Description
`NormalDist(NormalDist.Type type)`
Constructor
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```cdf(double x, double mu, double sigma)```
Cdf with given mean and standard deviation
`java.lang.Object` `eval(java.lang.Object[] args)`
Evaluate the function
`static double` ```pdf(double x, double mu, double sigma)```
PDF with given mean and standard deviation
`static double` `phi(double z)`
Standardised normal pdf with mean 0 and sd 1.
`static double` `Phi(double z)`
Standardised normal pdf with mean 0 and sd 1.
• ### Methods inherited from class com.singularsys.jep.functions.NaryFunction

`run`
• ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

`asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Constructor Detail

• #### NormalDist

`public NormalDist(NormalDist.Type type)`
Constructor
Parameters:
`type` - the mode for the distribution pdf/cdf/ fourarg version.
• ### Method Detail

• #### eval

```public java.lang.Object eval(java.lang.Object[] args)
throws EvaluationException```
Description copied from class: `NaryFunction`
Evaluate the function
Specified by:
`eval` in class `NaryFunction`
Parameters:
`args` - arguments to the function
Returns:
value returned by the function
Throws:
`EvaluationException` - if the calculation cannot be performed
• #### pdf

```public static double pdf(double x,
double mu,
double sigma)```
PDF with given mean and standard deviation
Parameters:
`x` - value to test
`mu` - mean
`sigma` - standard deviation
Returns:
pdf
• #### phi

`public static double phi(double z)`
Standardised normal pdf with mean 0 and sd 1.
Parameters:
`z` - z-statistic
Returns:
φ(z)
• #### cdf

```public static double cdf(double x,
double mu,
double sigma)```
Cdf with given mean and standard deviation
Parameters:
`x` - test value
`mu` - mean
`sigma` - standard deviation
Returns:
cdf
• #### Phi

`public static double Phi(double z)`
Standardised normal pdf with mean 0 and sd 1.
Parameters:
`z` - z-value to test
Returns:
Φ(z)