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
    See Also:
    Serialized Form
    • 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)