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

Extends the class ContinuousDistribution for the gamma distribution [95]  (page 337) with shape parameter. More...

Inheritance diagram for umontreal.ssj.probdist.GammaDist:
umontreal.ssj.probdist.ContinuousDistribution umontreal.ssj.probdist.Distribution umontreal.ssj.probdist.ErlangDist umontreal.ssj.probdist.GammaDistFromMoments

Public Member Functions

 GammaDist (double alpha)
 Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda=1\).
 GammaDist (double alpha, double lambda)
 Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda\) = lambda.
 GammaDist (double alpha, double lambda, int d)
 Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda\) = lambda, and approximations of roughly d decimal digits of precision when computing functions.
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 getAlpha ()
 Return the parameter \(\alpha\) for this object.
double getLambda ()
 Return the parameter \(\lambda\) for 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 density (double alpha, double lambda, double x)
 Computes the density function ( fgamma ) at \(x\).
static double cdf (double alpha, double lambda, int d, double x)
 Returns an approximation of the gamma distribution function with parameters \(\alpha\) = alpha and \(\lambda\) = lambda, whose density is given by ( fgamma ).
static double cdf (double alpha, int d, double x)
 Equivalent to cdf (alpha, 1.0, d, x).
static double barF (double alpha, double lambda, int d, double x)
 Computes the complementary distribution function.
static double barF (double alpha, int d, double x)
 Same as barF(alpha, 1.0, d, x).
static double inverseF (double alpha, double lambda, int d, double u)
 Computes the inverse distribution function.
static double inverseF (double alpha, int d, double u)
 Same as inverseF(alpha, 1, d, u).
static double[] getMLE (double[] x, int n)
 Estimates the parameters \((\alpha,\lambda)\) of the gamma distribution using the maximum likelihood method, from the \(n\) observations \(x[i]\), \(i = 0, 1,…, n-1\).
static GammaDist getInstanceFromMLE (double[] x, int n)
 Creates a new instance of a gamma distribution with parameters.
static double getMean (double alpha, double lambda)
 Computes and returns the mean \(E[X] = \alpha/\lambda\) of the gamma distribution with parameters \(\alpha\) and \(\lambda\).
static double getVariance (double alpha, double lambda)
 Computes and returns the variance \(\mbox{Var}[X] = \alpha/\lambda^2\) of the gamma distribution with parameters.
static double getStandardDeviation (double alpha, double lambda)
 Computes and returns the standard deviation of the gamma distribution with parameters \(\alpha\) and \(\lambda\).

Detailed Description

Extends the class ContinuousDistribution for the gamma distribution [95]  (page 337) with shape parameter.

\(\alpha> 0\) and rate parameter \(\lambda> 0\). The density is

\[ f(x) = \frac{\lambda^{\alpha}x^{\alpha- 1}e^{-\lambda x}}{\Gamma(\alpha)}, \qquad\mbox{for } x > 0,\tag{fgamma} \]

where \(\Gamma\) is the gamma function, defined by

\[ \Gamma(\alpha) = \int_0^{\infty}x^{\alpha-1} e^{-x} dx. \tag{Gamma} \]

In particular, \(\Gamma(n) = (n-1)!\) when \(n\) is a positive integer.

Definition at line 49 of file GammaDist.java.

Constructor & Destructor Documentation

◆ GammaDist() [1/3]

umontreal.ssj.probdist.GammaDist.GammaDist ( double alpha)

Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda=1\).

Definition at line 94 of file GammaDist.java.

◆ GammaDist() [2/3]

umontreal.ssj.probdist.GammaDist.GammaDist ( double alpha,
double lambda )

Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda\) = lambda.

Definition at line 102 of file GammaDist.java.

◆ GammaDist() [3/3]

umontreal.ssj.probdist.GammaDist.GammaDist ( double alpha,
double lambda,
int d )

Constructs a GammaDist object with parameters \(\alpha\) = alpha and \(\lambda\) = lambda, and approximations of roughly d decimal digits of precision when computing functions.

Definition at line 111 of file GammaDist.java.

Member Function Documentation

◆ barF() [1/3]

double umontreal.ssj.probdist.GammaDist.barF ( double alpha,
double lambda,
int d,
double x )
static

Computes the complementary distribution function.

Definition at line 266 of file GammaDist.java.

◆ barF() [2/3]

double umontreal.ssj.probdist.GammaDist.barF ( double alpha,
int d,
double x )
static

Same as barF(alpha, 1.0, d, x).

Definition at line 273 of file GammaDist.java.

◆ barF() [3/3]

double umontreal.ssj.probdist.GammaDist.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.

Definition at line 162 of file GammaDist.java.

◆ cdf() [1/3]

double umontreal.ssj.probdist.GammaDist.cdf ( double alpha,
double lambda,
int d,
double x )
static

Returns an approximation of the gamma distribution function with parameters \(\alpha\) = alpha and \(\lambda\) = lambda, whose density is given by ( fgamma ).

The approximation is an improved version of the algorithm in

[18] . The function tries to return \(d\) decimals digits of precision. For \(\alpha\) not too large (e.g., \(\alpha\le1000\)), \(d\) gives a good idea of the precision attained.

Definition at line 212 of file GammaDist.java.

◆ cdf() [2/3]

double umontreal.ssj.probdist.GammaDist.cdf ( double alpha,
int d,
double x )
static

Equivalent to cdf (alpha, 1.0, d, x).

Definition at line 219 of file GammaDist.java.

◆ cdf() [3/3]

double umontreal.ssj.probdist.GammaDist.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.

Definition at line 158 of file GammaDist.java.

◆ density() [1/2]

double umontreal.ssj.probdist.GammaDist.density ( double alpha,
double lambda,
double x )
static

Computes the density function ( fgamma ) at \(x\).

Definition at line 186 of file GammaDist.java.

◆ density() [2/2]

double umontreal.ssj.probdist.GammaDist.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 148 of file GammaDist.java.

◆ getAlpha()

double umontreal.ssj.probdist.GammaDist.getAlpha ( )

Return the parameter \(\alpha\) for this object.

Definition at line 511 of file GammaDist.java.

◆ getInstanceFromMLE()

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

Creates a new instance of a gamma distribution with parameters.

\(\alpha\) and \(\lambda\) 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

Reimplemented in umontreal.ssj.probdist.ErlangDist.

Definition at line 456 of file GammaDist.java.

◆ getLambda()

double umontreal.ssj.probdist.GammaDist.getLambda ( )

Return the parameter \(\lambda\) for this object.

Definition at line 518 of file GammaDist.java.

◆ getMean() [1/2]

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

Returns the mean.

Returns
the mean

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 170 of file GammaDist.java.

◆ getMean() [2/2]

double umontreal.ssj.probdist.GammaDist.getMean ( double alpha,
double lambda )
static

Computes and returns the mean \(E[X] = \alpha/\lambda\) of the gamma distribution with parameters \(\alpha\) and \(\lambda\).

Returns
the mean of the gamma distribution \(E[X] = \alpha/ \lambda\)

Definition at line 467 of file GammaDist.java.

◆ getMLE()

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

Estimates the parameters \((\alpha,\lambda)\) of the gamma 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: [ \(\alpha\), \(\lambda\)]. The maximum likelihood estimators are the values

\((\hat{\alpha}, \hat{\lambda})\) that satisfy the equations:

\begin{align*} \frac{1}{n} \sum_{i=1}^n \ln(x_i) - \ln(\bar{x}_n) & = \psi(\hat{\alpha}) - \ln(\hat{\alpha}) \\ \hat{\lambda} \bar{x}_n & = \hat{\alpha} \end{align*}

where \(\bar{x}_n\) is the average of \(x[0],…,x[n-1]\), and \(\psi\) is the logarithmic derivative of the Gamma function \(\psi(x) = \Gamma’(x) / \Gamma(x)\) ([95]  (page 361)).

Parameters
xthe list of observations to use to evaluate parameters
nthe number of observations to use to evaluate parameters
Returns
returns the parameters [ \(\hat{\alpha}\), \(\hat{\lambda}\)]

Reimplemented in umontreal.ssj.probdist.ErlangDist.

Definition at line 409 of file GammaDist.java.

◆ getParams()

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

Return a table containing the parameters of the current distribution.

This table is put in regular order: [ \(\alpha\), \(\lambda\)].

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.ErlangDist.

Definition at line 539 of file GammaDist.java.

◆ getStandardDeviation() [1/2]

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

Returns the standard deviation.

Returns
the standard deviation

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 178 of file GammaDist.java.

◆ getStandardDeviation() [2/2]

double umontreal.ssj.probdist.GammaDist.getStandardDeviation ( double alpha,
double lambda )
static

Computes and returns the standard deviation of the gamma distribution with parameters \(\alpha\) and \(\lambda\).

Returns
the standard deviation of the gamma distribution

Definition at line 499 of file GammaDist.java.

◆ getVariance() [1/2]

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

Returns the variance.

Returns
the variance

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 174 of file GammaDist.java.

◆ getVariance() [2/2]

double umontreal.ssj.probdist.GammaDist.getVariance ( double alpha,
double lambda )
static

Computes and returns the variance \(\mbox{Var}[X] = \alpha/\lambda^2\) of the gamma distribution with parameters.

\(\alpha\) and \(\lambda\).

Returns
the variance of the gamma distribution \(\mbox{Var}[X] = \alpha/ \lambda^2\)

Definition at line 484 of file GammaDist.java.

◆ inverseF() [1/3]

double umontreal.ssj.probdist.GammaDist.inverseF ( double alpha,
double lambda,
int d,
double u )
static

Computes the inverse distribution function.

Definition at line 343 of file GammaDist.java.

◆ inverseF() [2/3]

double umontreal.ssj.probdist.GammaDist.inverseF ( double alpha,
int d,
double u )
static

Same as inverseF(alpha, 1, d, u).

Definition at line 350 of file GammaDist.java.

◆ inverseF() [3/3]

double umontreal.ssj.probdist.GammaDist.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.

Definition at line 166 of file GammaDist.java.

◆ toString()

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

Returns a String containing information about the current distribution.

Reimplemented in umontreal.ssj.probdist.ErlangDist.

Definition at line 547 of file GammaDist.java.


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