SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.probdist.NormalDist Class Reference

Extends the class ContinuousDistribution for the normal distribution (e.g., [95]  (page 80)). More...

Inheritance diagram for umontreal.ssj.probdist.NormalDist:
umontreal.ssj.probdist.ContinuousDistribution umontreal.ssj.probdist.Distribution umontreal.ssj.probdist.NormalDistQuick

Public Member Functions

 NormalDist ()
 Constructs a NormalDist object with default parameters \(\mu= 0\) and \(\sigma= 1\).
 NormalDist (double mu, double sigma)
 Constructs a NormalDist object with mean \(\mu\) = mu and standard deviation \(\sigma\) = sigma.
double density (double x)
 Returns \(f(x)\), the density evaluated at \(x\).
double cdf (double x)
 Returns the distribution function \(F(x)\).
double barF (double x)
 Returns the complementary distribution function.
double inverseF (double u)
 Returns the inverse distribution function \(x = F^{-1}(u)\).
double getMean ()
 Returns the mean.
double getVariance ()
 Returns the variance.
double getStandardDeviation ()
 Returns the standard deviation.
double getMu ()
 Returns the parameter \(\mu\).
double getSigma ()
 Returns the parameter \(\sigma\).
void setParams (double mu, double sigma)
 Sets the parameters \(\mu\) and \(\sigma\) of this object.
double[] getParams ()
 Return a table containing the parameters of the current distribution.
String toString ()
 Returns a String containing information about the current distribution.
Public Member Functions inherited from umontreal.ssj.probdist.ContinuousDistribution
double inverseBrent (double a, double b, double u, double tol)
 Computes the inverse distribution function \(x = F^{-1}(u)\), using the Brent-Dekker method.
double inverseBisection (double u)
 Computes and returns the inverse distribution function \(x = F^{-1}(u)\), using bisection.
double getXinf ()
 Returns \(x_a\) such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
double getXsup ()
 Returns \(x_b\) such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
void setXinf (double xa)
 Sets the value \(x_a=\) xa, such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
void setXsup (double xb)
 Sets the value \(x_b=\) xb, such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).

Static Public Member Functions

static double density01 (double x)
 Same as density(0, 1, x).
static double density (double mu, double sigma, double x)
 Computes the normal density function ( fnormal ).
static double cdf01 (double x)
 Same as cdf(0, 1, x).
static double cdf (double mu, double sigma, double x)
 Computes the normal distribution function with mean \(\mu\) and variance \(\sigma^2\).
static double barF01 (double x)
 Same as barF(0, 1, x).
static double barF (double mu, double sigma, double x)
 Computes the complementary normal distribution function.
static double inverseF01 (double u)
 Same as inverseF(0, 1, u).
static double inverseF (double mu, double sigma, double u)
 Computes the inverse normal distribution function with mean.
static double[] getMLE (double[] x, int n)
 Estimates the parameters \((\mu, \sigma)\) of the normal distribution using the maximum likelihood method, from the \(n\) observations \(x[i]\), \(i = 0, 1,…, n-1\).
static NormalDist getInstanceFromMLE (double[] x, int n)
 Creates a new instance of a normal distribution with parameters.
static double getMean (double mu, double sigma)
 Computes and returns the mean \(E[X] = \mu\) of the normal distribution with parameters \(\mu\) and \(\sigma\).
static double getVariance (double mu, double sigma)
 Computes and returns the variance \(\mbox{Var}[X] = \sigma^2\) of the normal distribution with parameters \(\mu\) and.
static double getStandardDeviation (double mu, double sigma)
 Computes and returns the standard deviation \(\sigma\) of the normal distribution with parameters \(\mu\) and \(\sigma\).

Detailed Description

Extends the class ContinuousDistribution for the normal distribution (e.g., [95]  (page 80)).

It has mean

\(\mu\) and variance \(\sigma^2\). Its density function is

\[ f (x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-(x-\mu)^2/(2\sigma^2)} \qquad\mbox{for } -\infty< x < \infty, \tag{fnormal} \]

where \(\sigma> 0\). When \(\mu=0\) and \(\sigma=1\), we have the standard normal distribution, with corresponding distribution function

\[ F(x) = \Phi(x) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x e^{-t^2/2} dt \qquad\mbox{for } -\infty< x < \infty. \tag{cdfnormal} \]

The non-static methods cdf, barF, and inverseF are implemented via cdf01, barF01, and inverseF01, respectively.

Definition at line 49 of file NormalDist.java.

Constructor & Destructor Documentation

◆ NormalDist() [1/2]

umontreal.ssj.probdist.NormalDist.NormalDist ( )

Constructs a NormalDist object with default parameters \(\mu= 0\) and \(\sigma= 1\).

Definition at line 66 of file NormalDist.java.

◆ NormalDist() [2/2]

umontreal.ssj.probdist.NormalDist.NormalDist ( double mu,
double sigma )

Constructs a NormalDist object with mean \(\mu\) = mu and standard deviation \(\sigma\) = sigma.

Definition at line 74 of file NormalDist.java.

Member Function Documentation

◆ barF() [1/2]

double umontreal.ssj.probdist.NormalDist.barF ( double mu,
double sigma,
double x )
static

Computes the complementary normal distribution function.

\(\bar{F}(x) = 1 - \Phi((x-\mu)/\sigma)\), with mean \(\mu\) and variance \(\sigma^2\). Uses a Chebyshev series giving 16 decimal digits of precision [204] .

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 229 of file NormalDist.java.

◆ barF() [2/2]

double umontreal.ssj.probdist.NormalDist.barF ( double x)

Returns the complementary distribution function.

The default implementation computes \(\bar{F}(x) = 1 - F(x)\).

Parameters
xvalue at which the complementary distribution function is evaluated
Returns
complementary distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 87 of file NormalDist.java.

◆ barF01()

double umontreal.ssj.probdist.NormalDist.barF01 ( double x)
static

Same as barF(0, 1, x).

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 190 of file NormalDist.java.

◆ cdf() [1/2]

double umontreal.ssj.probdist.NormalDist.cdf ( double mu,
double sigma,
double x )
static

Computes the normal distribution function with mean \(\mu\) and variance \(\sigma^2\).

Uses the Chebyshev approximation proposed in [204] , which gives 16 decimals of precision.

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 181 of file NormalDist.java.

◆ cdf() [2/2]

double umontreal.ssj.probdist.NormalDist.cdf ( double x)

Returns the distribution function \(F(x)\).

Parameters
xvalue at which the distribution function is evaluated
Returns
distribution function evaluated at x

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 83 of file NormalDist.java.

◆ cdf01()

double umontreal.ssj.probdist.NormalDist.cdf01 ( double x)
static

Same as cdf(0, 1, x).

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 151 of file NormalDist.java.

◆ density() [1/2]

double umontreal.ssj.probdist.NormalDist.density ( double mu,
double sigma,
double x )
static

Computes the normal density function ( fnormal ).

Definition at line 118 of file NormalDist.java.

◆ density() [2/2]

double umontreal.ssj.probdist.NormalDist.density ( double x)

Returns \(f(x)\), the density evaluated at \(x\).

Parameters
xvalue at which the density is evaluated
Returns
density function evaluated at x

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 78 of file NormalDist.java.

◆ density01()

double umontreal.ssj.probdist.NormalDist.density01 ( double x)
static

Same as density(0, 1, x).

Definition at line 110 of file NormalDist.java.

◆ getInstanceFromMLE()

NormalDist umontreal.ssj.probdist.NormalDist.getInstanceFromMLE ( double[] x,
int n )
static

Creates a new instance of a normal distribution with parameters.

\(\mu\) and \(\sigma\) estimated using the maximum likelihood method based on the \(n\) observations \(x[i]\), \(i = 0, 1, …, n-1\).

Parameters
xthe list of observations to use to evaluate parameters
nthe number of observations to use to evaluate parameters

Definition at line 402 of file NormalDist.java.

◆ getMean() [1/2]

double umontreal.ssj.probdist.NormalDist.getMean ( )

Returns the mean.

Returns
the mean

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 95 of file NormalDist.java.

◆ getMean() [2/2]

double umontreal.ssj.probdist.NormalDist.getMean ( double mu,
double sigma )
static

Computes and returns the mean \(E[X] = \mu\) of the normal distribution with parameters \(\mu\) and \(\sigma\).

Returns
the mean of the normal distribution \(E[X] = \mu\)

Definition at line 413 of file NormalDist.java.

◆ getMLE()

double[] umontreal.ssj.probdist.NormalDist.getMLE ( double[] x,
int n )
static

Estimates the parameters \((\mu, \sigma)\) of the normal distribution using the maximum likelihood method, from the \(n\) observations \(x[i]\), \(i = 0, 1,…, n-1\).

The estimates are returned in a two-element array, in regular order: [ \(\hat{\mu}\), \(\hat{\sigma}\)]. The maximum likelihood estimators are the values \((\hat{\mu}, \hat{\sigma})\) that satisfy the equations:

\begin{align*} \hat{\mu} & = \bar{x}_n = \frac{1}{n} \sum_{i=1}^n x_i \\ \hat{\sigma} & = \sqrt{\frac{1}{n} \sum_{i=1}^n (x_i - \bar{x}_n)^2}. \end{align*}

See [95]  (page 123).

Parameters
xthe list of observations used to evaluate parameters
nthe number of observations used to evaluate parameters
Returns
returns the parameters [ \(\hat{\mu}\), \(\hat{\sigma}\)]

Definition at line 375 of file NormalDist.java.

◆ getMu()

double umontreal.ssj.probdist.NormalDist.getMu ( )

Returns the parameter \(\mu\).

Definition at line 447 of file NormalDist.java.

◆ getParams()

double[] umontreal.ssj.probdist.NormalDist.getParams ( )

Return a table containing the parameters of the current distribution.

This table is put in regular order: [ \(\mu\), \(\sigma\)].

Implements umontreal.ssj.probdist.Distribution.

Definition at line 472 of file NormalDist.java.

◆ getSigma()

double umontreal.ssj.probdist.NormalDist.getSigma ( )

Returns the parameter \(\sigma\).

Definition at line 454 of file NormalDist.java.

◆ getStandardDeviation() [1/2]

double umontreal.ssj.probdist.NormalDist.getStandardDeviation ( )

Returns the standard deviation.

Returns
the standard deviation

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 103 of file NormalDist.java.

◆ getStandardDeviation() [2/2]

double umontreal.ssj.probdist.NormalDist.getStandardDeviation ( double mu,
double sigma )
static

Computes and returns the standard deviation \(\sigma\) of the normal distribution with parameters \(\mu\) and \(\sigma\).

Returns
the standard deviation of the normal distribution

Definition at line 440 of file NormalDist.java.

◆ getVariance() [1/2]

double umontreal.ssj.probdist.NormalDist.getVariance ( )

Returns the variance.

Returns
the variance

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 99 of file NormalDist.java.

◆ getVariance() [2/2]

double umontreal.ssj.probdist.NormalDist.getVariance ( double mu,
double sigma )
static

Computes and returns the variance \(\mbox{Var}[X] = \sigma^2\) of the normal distribution with parameters \(\mu\) and.

\(\sigma\).

Returns
the variance of the normal distribution \(\mbox{Var}[X] = \sigma^2\)

Definition at line 427 of file NormalDist.java.

◆ inverseF() [1/2]

double umontreal.ssj.probdist.NormalDist.inverseF ( double mu,
double sigma,
double u )
static

Computes the inverse normal distribution function with mean.

\(\mu\) and variance \(\sigma^2\). Uses different rational Chebyshev approximations [20] . Returns 16 decimal digits of precision for \(2.2\times10^{-308} < u < 1\).

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 352 of file NormalDist.java.

◆ inverseF() [2/2]

double umontreal.ssj.probdist.NormalDist.inverseF ( double u)

Returns the inverse distribution function \(x = F^{-1}(u)\).

Restrictions: \(u \in[0,1]\).

Parameters
uvalue at which the inverse distribution function is evaluated
Returns
the inverse distribution function evaluated at u
Exceptions
IllegalArgumentExceptionif \(u\) is not in the interval \([0,1]\)

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 91 of file NormalDist.java.

◆ inverseF01()

double umontreal.ssj.probdist.NormalDist.inverseF01 ( double u)
static

Same as inverseF(0, 1, u).

Reimplemented in umontreal.ssj.probdist.NormalDistQuick.

Definition at line 262 of file NormalDist.java.

◆ setParams()

void umontreal.ssj.probdist.NormalDist.setParams ( double mu,
double sigma )

Sets the parameters \(\mu\) and \(\sigma\) of this object.

Definition at line 461 of file NormalDist.java.

◆ toString()

String umontreal.ssj.probdist.NormalDist.toString ( )

Returns a String containing information about the current distribution.

Definition at line 480 of file NormalDist.java.


The documentation for this class was generated from the following file: