Class Normal

    • Constructor Summary

      Constructors 
      Constructor Description
      Normal()
      Constructs a normal distribution with mean 0.0 and variance 1.0
      Normal​(double[] parameters)
      Constructs a normal distribution with mean = parameters[0] and variance = parameters[1]
      Normal​(double mean, double variance)
      Constructs a normal distribution with mean and variance.
      Normal​(double mean, double variance, java.lang.String name)
      Constructs a normal distribution with mean and variance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double cdf​(double x)
      Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
      double complementaryCDF​(double x)
      Computes the complementary cumulative probability distribution function for given value of x
      double firstOrderLossFunction​(double x)
      Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]
      Interval getDomain()  
      double getKurtosis()
      Gets the kurtosis of the distribution
      double getMean()
      Returns the mean or expected value of a distribution
      double[] getParameters()
      Gets the parameters for the distribution
      RVariableIfc getRandomVariable​(RNStreamIfc rng)  
      double getSkewness()
      Gets the skewness of the distribution
      double getVariance()
      Returns the variance of the distribution if defined
      double invCDF​(double p)
      Provides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.
      Normal newInstance()
      Returns a new instance
      double pdf​(double x)
      Returns the f(x) where f represents the probability density function for the distribution.
      double secondOrderLossFunction​(double x)
      Computes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]
      void setMean​(double mean)
      Sets the mean of this normal distribution
      void setParameters​(double[] parameters)
      Sets the parameters for the distribution mean = parameters[0] and variance = parameters[1]
      void setVariance​(double variance)
      Sets the variance of this normal distribution
      static double stdNormalCDF​(double z)
      Computes the cumulative distribution function for a standard normal distribution using Taylor approximation.
      static double stdNormalCDFAbramovitzAndStegun​(double z)
      Computes the cumulative distribution function for a standard normal distribution from Abramovitz and Stegun, see also Didier H.
      static double stdNormalComplementaryCDF​(double z)
      Computes the complementary cumulative probability for the standard normal distribution function for given value of z
      static double stdNormalFirstOrderLossFunction​(double z)
      Computes the first order loss function for the standard normal distribution function for given value of x, G1(z) = E[max(Z-z,0)]
      static double stdNormalInvCDF​(double p)
      Computes the inverse cumulative distribution function for a standard normal distribution see, W.
      static double stdNormalPDF​(double z)
      Computes the pdf function for a standard normal distribution from Abramovitz and Stegun, see also Didier H.
      static double stdNormalSecondOrderLossFunction​(double z)
      Computes the 2nd order loss function for the standard normal distribution function for given value of z, G2(z) = (1/2)E[max(Z-z,0)*max(Z-z-1,0)]
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface jsl.utilities.distributions.CDFIfc

        cdf
    • Constructor Detail

      • Normal

        public Normal()
        Constructs a normal distribution with mean 0.0 and variance 1.0
      • Normal

        public Normal​(double[] parameters)
        Constructs a normal distribution with mean = parameters[0] and variance = parameters[1]
        Parameters:
        parameters - An array with the mean and variance
      • Normal

        public Normal​(double mean,
                      double variance)
        Constructs a normal distribution with mean and variance.
        Parameters:
        mean - of the distribution
        variance - must be > 0
      • Normal

        public Normal​(double mean,
                      double variance,
                      java.lang.String name)
        Constructs a normal distribution with mean and variance.
        Parameters:
        mean - of the distribution
        variance - must be > 0
        name - an optional name/label
    • Method Detail

      • setMean

        public final void setMean​(double mean)
        Sets the mean of this normal distribution
        Parameters:
        mean - of the distribution
      • getMean

        public final double getMean()
        Description copied from interface: MeanIfc
        Returns the mean or expected value of a distribution
        Specified by:
        getMean in interface MeanIfc
        Returns:
        double the mean or expected value for the distribution
      • setVariance

        public final void setVariance​(double variance)
        Sets the variance of this normal distribution
        Parameters:
        variance - of the distribution, must be > 0
      • getVariance

        public final double getVariance()
        Description copied from interface: VarianceIfc
        Returns the variance of the distribution if defined
        Specified by:
        getVariance in interface VarianceIfc
        Returns:
        double the variance of the random variable
      • stdNormalCDFAbramovitzAndStegun

        public static double stdNormalCDFAbramovitzAndStegun​(double z)
        Computes the cumulative distribution function for a standard normal distribution from Abramovitz and Stegun, see also Didier H. Besset Object-oriented Implementation of Numerical Methods, Morgan-Kaufmann (2001)
        Parameters:
        z - the z-ordinate to be evaluated
        Returns:
        the P(Z<=z) for standard normal
      • stdNormalCDF

        public static double stdNormalCDF​(double z)
        Computes the cumulative distribution function for a standard normal distribution using Taylor approximation. The approximation is accurate to absolute error less than 8 * 10^(-16). * Reference: Evaluating the Normal Distribution by George Marsaglia. * http://www.jstatsoft.org/v11/a04/paper
        Parameters:
        z - the z-ordinate to be evaluated
        Returns:
        the P(Z<=z) for standard normal
      • stdNormalPDF

        public static double stdNormalPDF​(double z)
        Computes the pdf function for a standard normal distribution from Abramovitz and Stegun, see also Didier H. Besset Object-oriented Implementation of Numerical Methods, Morgan-Kaufmann (2001)
        Parameters:
        z - the z-ordinate to be evaluated
        Returns:
        the f(z) for standard normal
      • stdNormalInvCDF

        public static double stdNormalInvCDF​(double p)
        Computes the inverse cumulative distribution function for a standard normal distribution see, W. J. Cody, Rational Chebyshev approximations for the error function Math. Comp. pp 631-638 this is without the extra refinement and has relative error of 1.15e-9 http://www.math.uio.no/~jacklam/notes/invnorm/
        Parameters:
        p - the probability to be evaluated, p must be within [0,1] p = 0.0 returns Double.NEGATIVE_INFINTITY p = 1.0 returns Double.POSITIVE_INFINITY
        Returns:
        the "z" value associated with the p
      • stdNormalComplementaryCDF

        public static double stdNormalComplementaryCDF​(double z)
        Computes the complementary cumulative probability for the standard normal distribution function for given value of z
        Parameters:
        z - The value to be evaluated
        Returns:
        The probability, 1-P{X<=z}
      • stdNormalFirstOrderLossFunction

        public static double stdNormalFirstOrderLossFunction​(double z)
        Computes the first order loss function for the standard normal distribution function for given value of x, G1(z) = E[max(Z-z,0)]
        Parameters:
        z - The value to be evaluated
        Returns:
        The loss function value, E[max(Z-z,0)]
      • stdNormalSecondOrderLossFunction

        public static double stdNormalSecondOrderLossFunction​(double z)
        Computes the 2nd order loss function for the standard normal distribution function for given value of z, G2(z) = (1/2)E[max(Z-z,0)*max(Z-z-1,0)]
        Parameters:
        z - The value to be evaluated
        Returns:
        The loss function value, (1/2)E[max(Z-z,0)*max(Z-z-1,0)]
      • cdf

        public final double cdf​(double x)
        Description copied from interface: CDFIfc
        Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
        Specified by:
        cdf in interface CDFIfc
        Parameters:
        x - a double representing the upper limit
        Returns:
        a double representing the probability
      • pdf

        public final double pdf​(double x)
        Description copied from interface: PDFIfc
        Returns the f(x) where f represents the probability density function for the distribution. Note this is not a probability.
        Specified by:
        pdf in interface PDFIfc
        Parameters:
        x - a double representing the value to be evaluated
        Returns:
        f(x)
      • invCDF

        public final double invCDF​(double p)
        Description copied from interface: InverseCDFIfc
        Provides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.
        Specified by:
        invCDF in interface InverseCDFIfc
        Parameters:
        p - The probability to be evaluated for the inverse, p must be [0,1] or an IllegalArgumentException is thrown
        Returns:
        The inverse cdf evaluated at the supplied probability
      • getKurtosis

        public final double getKurtosis()
        Gets the kurtosis of the distribution
        Returns:
        the kurtosis
      • getSkewness

        public final double getSkewness()
        Gets the skewness of the distribution
        Returns:
        the skewness
      • complementaryCDF

        public double complementaryCDF​(double x)
        Description copied from interface: CDFIfc
        Computes the complementary cumulative probability distribution function for given value of x
        Specified by:
        complementaryCDF in interface CDFIfc
        Parameters:
        x - The value to be evaluated
        Returns:
        The probability, 1-P{X<=x}
      • firstOrderLossFunction

        public double firstOrderLossFunction​(double x)
        Description copied from interface: FirstOrderLossFunctionIfc
        Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]
        Specified by:
        firstOrderLossFunction in interface FirstOrderLossFunctionIfc
        Parameters:
        x - The value to be evaluated
        Returns:
        The loss function value, E[max(X-x,0)]
      • secondOrderLossFunction

        public double secondOrderLossFunction​(double x)
        Description copied from interface: SecondOrderLossFunctionIfc
        Computes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]
        Specified by:
        secondOrderLossFunction in interface SecondOrderLossFunctionIfc
        Parameters:
        x - The value to be evaluated
        Returns:
        The loss function value, (1/2)E[max(X-x,0)*max(X-x-1,0)]
      • setParameters

        public void setParameters​(double[] parameters)
        Sets the parameters for the distribution mean = parameters[0] and variance = parameters[1]
        Specified by:
        setParameters in interface ParametersIfc
        Parameters:
        parameters - an array of doubles representing the parameters for the distribution
      • getParameters

        public double[] getParameters()
        Gets the parameters for the distribution
        Specified by:
        getParameters in interface ParametersIfc
        Returns:
        Returns an array of the parameters for the distribution