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

Extends the class ContinuousDistribution for the chi-square distribution with \(n\) degrees of freedom, where \(n\) is a positive integer [95]  (page 416). More...

Inheritance diagram for umontreal.ssj.probdist.ChiSquareDist:
umontreal.ssj.probdist.ContinuousDistribution umontreal.ssj.probdist.Distribution umontreal.ssj.probdist.ChiSquareDistQuick

Public Member Functions

 ChiSquareDist (int n)
 Constructs a chi-square distribution with n degrees of freedom.
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.
int getN ()
 Returns the parameter \(n\) of this object.
void setN (int n)
 Sets the parameter \(n\) 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 density (int n, double x)
 Computes the density function ( Fchi2 ) for a chi-square distribution with \(n\) degrees of freedom.
static double cdf (int n, int d, double x)
 Computes the chi-square distribution function with \(n\) degrees of freedom, evaluated at \(x\).
static double barF (int n, int d, double x)
 Computes the complementary chi-square distribution function with.
static double inverseF (int n, double u)
 Computes an approximation of \(F^{-1}(u)\), where \(F\) is the chi-square distribution with \(n\) degrees of freedom.
static double[] getMLE (double[] x, int m)
 Estimates the parameter \(n\) of the chi-square distribution using the maximum likelihood method, from the \(m\) observations.
static ChiSquareDist getInstanceFromMLE (double[] x, int m)
 Creates a new instance of a chi-square distribution with parameter.
static double getMean (int n)
 Computes and returns the mean \(E[X] = n\) of the chi-square distribution with parameter \(n\).
static double[] getMomentsEstimate (double[] x, int m)
 Estimates and returns the parameter [ \(\hat{n}\)] of the chi-square distribution using the moments method based on the.
static double getVariance (int n)
 Returns the variance \(\mbox{Var}[X] = 2n\) of the chi-square distribution with parameter \(n\).
static double getStandardDeviation (int n)
 Returns the standard deviation of the chi-square distribution with parameter \(n\).

Detailed Description

Extends the class ContinuousDistribution for the chi-square distribution with \(n\) degrees of freedom, where \(n\) is a positive integer [95]  (page 416).

Its density is

\[ f(x) = \frac{x^{(n/2)-1}e^{-x/2}}{2^{n/2}\Gamma(n/2)},\qquad\mbox{for } x > 0 \tag{Fchi2} \]

where \(\Gamma(x)\) is the gamma function defined in ( Gamma ). The chi-square distribution is a special case of the gamma distribution with shape parameter \(n/2\) and scale parameter \(1/2\). Therefore, one can use the methods of GammaDist for this distribution.

The non-static versions of the methods cdf, barF, and inverseF call the static version of the same name.

Definition at line 51 of file ChiSquareDist.java.

Constructor & Destructor Documentation

◆ ChiSquareDist()

umontreal.ssj.probdist.ChiSquareDist.ChiSquareDist ( int n)

Constructs a chi-square distribution with n degrees of freedom.

Definition at line 74 of file ChiSquareDist.java.

Member Function Documentation

◆ barF() [1/2]

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

◆ barF() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.barF ( int n,
int d,
double x )
static

Computes the complementary chi-square distribution function with.

\(n\) degrees of freedom, evaluated at \(x\). The method tries to return \(d\) decimals digits of precision, but there is no guarantee.

Definition at line 140 of file ChiSquareDist.java.

◆ cdf() [1/2]

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

◆ cdf() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.cdf ( int n,
int d,
double x )
static

Computes the chi-square distribution function with \(n\) degrees of freedom, evaluated at \(x\).

The method tries to return \(d\) decimals digits of precision, but there is no guarantee.

Definition at line 123 of file ChiSquareDist.java.

◆ density() [1/2]

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

◆ density() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.density ( int n,
double x )
static

Computes the density function ( Fchi2 ) for a chi-square distribution with \(n\) degrees of freedom.

Definition at line 112 of file ChiSquareDist.java.

◆ getInstanceFromMLE()

ChiSquareDist umontreal.ssj.probdist.ChiSquareDist.getInstanceFromMLE ( double[] x,
int m )
static

Creates a new instance of a chi-square distribution with parameter.

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

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

Definition at line 293 of file ChiSquareDist.java.

◆ getMean() [1/2]

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

Returns the mean.

Returns
the mean

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 96 of file ChiSquareDist.java.

◆ getMean() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.getMean ( int n)
static

Computes and returns the mean \(E[X] = n\) of the chi-square distribution with parameter \(n\).

Returns
the mean of the Chi-square distribution \(E[X] = n\)

Definition at line 304 of file ChiSquareDist.java.

◆ getMLE()

double[] umontreal.ssj.probdist.ChiSquareDist.getMLE ( double[] x,
int m )
static

Estimates the parameter \(n\) of the chi-square distribution using the maximum likelihood method, from the \(m\) observations.

\(x[i]\), \(i = 0, 1, …, m-1\). The estimate is returned in element 0 of the returned array.

Parameters
xthe list of observations to use to evaluate parameters
mthe number of observations to use to evaluate parameters
Returns
returns the parameter [ \(\hat{n}\)]

Definition at line 258 of file ChiSquareDist.java.

◆ getMomentsEstimate()

double[] umontreal.ssj.probdist.ChiSquareDist.getMomentsEstimate ( double[] x,
int m )
static

Estimates and returns the parameter [ \(\hat{n}\)] of the chi-square distribution using the moments method based on the.

\(m\) observations in table \(x[i]\), \(i = 0, 1, …, m-1\).

Parameters
xthe list of observations to use to evaluate parameters
mthe number of observations to use to evaluate parameters
Returns
returns the parameter [ \(\hat{n}\)]

Definition at line 320 of file ChiSquareDist.java.

◆ getN()

int umontreal.ssj.probdist.ChiSquareDist.getN ( )

Returns the parameter \(n\) of this object.

Definition at line 360 of file ChiSquareDist.java.

◆ getParams()

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

Return a table containing the parameters of the current distribution.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 379 of file ChiSquareDist.java.

◆ getStandardDeviation() [1/2]

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

Returns the standard deviation.

Returns
the standard deviation

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 104 of file ChiSquareDist.java.

◆ getStandardDeviation() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.getStandardDeviation ( int n)
static

Returns the standard deviation of the chi-square distribution with parameter \(n\).

Returns
the standard deviation of the chi-square distribution

Definition at line 350 of file ChiSquareDist.java.

◆ getVariance() [1/2]

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

Returns the variance.

Returns
the variance

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 100 of file ChiSquareDist.java.

◆ getVariance() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.getVariance ( int n)
static

Returns the variance \(\mbox{Var}[X] = 2n\) of the chi-square distribution with parameter \(n\).

Returns
the variance of the chi-square distribution \(\mbox{Var}X] = 2n\)

Definition at line 337 of file ChiSquareDist.java.

◆ inverseF() [1/2]

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

Definition at line 92 of file ChiSquareDist.java.

◆ inverseF() [2/2]

double umontreal.ssj.probdist.ChiSquareDist.inverseF ( int n,
double u )
static

Computes an approximation of \(F^{-1}(u)\), where \(F\) is the chi-square distribution with \(n\) degrees of freedom.

Uses the approximation given in [16]  and in Figure L.23 of

[24] . It gives at least 6 decimal digits of precision, except far in the tails (that is, for \(u< 10^{-5}\) or \(u > 1 - 10^{-5}\)) where the function calls the method GammaDist.inverseF (n/2, 7, u) and multiplies the result by 2.0. To get better precision, one may call GammaDist.inverseF, but this method is slower than the current method, especially for large \(n\). For instance, for \(n = \) 16, 1024, and 65536, the GammaDist.inverseF method is 2, 5, and 8 times slower, respectively, than the current method.

Reimplemented in umontreal.ssj.probdist.ChiSquareDistQuick.

Definition at line 163 of file ChiSquareDist.java.

◆ setN()

void umontreal.ssj.probdist.ChiSquareDist.setN ( int n)

Sets the parameter \(n\) of this object.

Definition at line 367 of file ChiSquareDist.java.

◆ toString()

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

Returns a String containing information about the current distribution.

Definition at line 387 of file ChiSquareDist.java.


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