Class DistNormal

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DistLogNormal

public class DistNormal extends DistContinuous
The Normal distribution. For more information on this distribution see https://mathworld.wolfram.com/NormalDistribution.html

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Peter Jacobs , Alexander Verbraeck
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    haveNextNextGaussian is a helper attribute.
    double
    mu refers to the mean of the normal distribution.
    double
    sigma refers to the standard deviation of the normal distribution.

    Fields inherited from class nl.tudelft.simulation.jstats.distributions.Dist

    stream
  • Constructor Summary

    Constructors
    Constructor
    Description
    constructs a standard normal distribution with mu=0 and sigma=1.
    DistNormal(StreamInterface stream, double mu, double sigma)
    constructs a normal distribution with provided mu and sigma.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    draws the next stream value according to the probability of this this distribution.
    double
    returns the cumulative probability of the x-value.
    double
    getInverseCumulativeProbability(double cumulativeProbability)
    returns the x-value of the given cumulativePropability.
    double
     
    double
    returns the probability density value of a value x.
    double
     
    protected double
    Generates the next pseudorandom, Gaussian (normally) distributed double value, with mean 0.0 and standard deviation 1.0 see section 3.4.1 of The Art of Computer Programming, Volume 2 by Donald Knuth.
    void
    Replace the random number stream.

    Methods inherited from class nl.tudelft.simulation.jstats.distributions.Dist

    getStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • mu

      public double mu
      mu refers to the mean of the normal distribution.
    • sigma

      public double sigma
      sigma refers to the standard deviation of the normal distribution.
    • haveNextNextGaussian

      protected boolean haveNextNextGaussian
      haveNextNextGaussian is a helper attribute.
  • Constructor Details

    • DistNormal

      public DistNormal(StreamInterface stream)
      constructs a standard normal distribution with mu=0 and sigma=1. Models probabilities that are the sum of a large number of other probabilities by the virtue of the central limit theorem.
      Parameters:
      stream - StreamInterface; the random number stream
    • DistNormal

      public DistNormal(StreamInterface stream, double mu, double sigma)
      constructs a normal distribution with provided mu and sigma.
      Parameters:
      stream - StreamInterface; the random number stream
      mu - double; the mean
      sigma - double; the standard deviation
      Throws:
      IllegalArgumentException - when sigma <= 0
  • Method Details

    • draw

      public double draw()
      draws the next stream value according to the probability of this this distribution.
      Specified by:
      draw in class DistContinuous
      Returns:
      the next double value drawn.
    • getCumulativeProbability

      public double getCumulativeProbability(double x)
      returns the cumulative probability of the x-value.
      Parameters:
      x - double; the observation x
      Returns:
      double the cumulative probability
    • getInverseCumulativeProbability

      public double getInverseCumulativeProbability(double cumulativeProbability)
      returns the x-value of the given cumulativePropability.
      Parameters:
      cumulativeProbability - double; reflects cum prob
      Returns:
      double the inverse cumulative probability
    • nextGaussian

      protected double nextGaussian()
      Generates the next pseudorandom, Gaussian (normally) distributed double value, with mean 0.0 and standard deviation 1.0 see section 3.4.1 of The Art of Computer Programming, Volume 2 by Donald Knuth.
      Returns:
      double the next Gaussian value
    • getProbabilityDensity

      public double getProbabilityDensity(double x)
      returns the probability density value of a value x.
      Specified by:
      getProbabilityDensity in class DistContinuous
      Parameters:
      x - double; the value for which the density function needs to be calculated
      Returns:
      double; the probability density for value x
    • getMu

      public double getMu()
      Returns:
      mu
    • getSigma

      public double getSigma()
      Returns:
      sigma
    • setStream

      public void setStream(StreamInterface stream)
      Replace the random number stream.
      Overrides:
      setStream in class Dist
      Parameters:
      stream - StreamInterface; the new random number stream
    • toString

      public String toString()
      Overrides:
      toString in class Object