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

Extends the class DiscreteDistributionInt for the discrete uniform distribution over the range \([i,j]\). More...

Inheritance diagram for umontreal.ssj.probdist.UniformIntDist:
umontreal.ssj.probdist.DiscreteDistributionInt umontreal.ssj.probdist.Distribution umontreal.ssj.probdist.ConstantIntDist

Public Member Functions

 UniformIntDist (int i, int j)
 Constructs a discrete uniform distribution over the interval \([i,j]\).
double prob (int x)
 Returns \(p(x)\), the probability of \(x\).
double cdf (int x)
 Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).
double barF (int x)
 Returns \(\bar{F}(x)\), the complementary distribution function.
int inverseFInt (double u)
 Returns the inverse distribution function \(F^{-1}(u)\), where.
double getMean ()
 Returns the mean of the distribution function.
double getVariance ()
 Returns the variance of the distribution function.
double getStandardDeviation ()
 Returns the standard deviation of the distribution function.
int getI ()
 Returns the parameter \(i\).
int getJ ()
 Returns the parameter \(j\).
void setParams (int i, int j)
 Sets the parameters \(i\) and \(j\) 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.DiscreteDistributionInt
double cdf (double x)
 Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).
double barF (double x)
 Returns \(\bar{F}(x)\), the complementary distribution function.
int getXinf ()
 Returns the lower limit \(x_a\) of the support of the probability mass function.
int getXsup ()
 Returns the upper limit \(x_b\) of the support of the probability mass function.
double inverseF (double u)
 Returns the inverse distribution function \(F^{-1}(u)\), where.

Static Public Member Functions

static double prob (int i, int j, int x)
 Computes the discrete uniform probability \(p(x)\) defined in ( fmassuniformint ).
static double cdf (int i, int j, int x)
 Computes the discrete uniform distribution function defined in ( cdfuniformint ).
static double barF (int i, int j, int x)
 Computes the discrete uniform complementary distribution function.
static int inverseF (int i, int j, double u)
 Computes the inverse of the discrete uniform distribution function ( invuniformint ).
static double[] getMLE (int[] x, int n)
 Estimates the parameters \((i, j)\) of the uniform distribution over integers using the maximum likelihood method, from the \(n\) observations \(x[k]\), \(k = 0, 1, …, n-1\).
static UniformIntDist getInstanceFromMLE (int[] x, int n)
 Creates a new instance of a discrete uniform distribution over integers with parameters \(i\) and \(j\) estimated using the maximum likelihood method based on the \(n\) observations.
static double getMean (int i, int j)
 Computes and returns the mean \(E[X] = (i + j)/2\) of the discrete uniform distribution.
static double getVariance (int i, int j)
 Computes and returns the variance \(\mbox{Var}[X] = [(j - i + 1)^2 - 1]/{12}\) of the discrete uniform distribution.
static double getStandardDeviation (int i, int j)
 Computes and returns the standard deviation of the discrete uniform distribution.

Additional Inherited Members

Static Public Attributes inherited from umontreal.ssj.probdist.DiscreteDistributionInt
static double EPSILON = 1.0e-16
 Environment variable that determines what probability terms can be considered as negligible when building precomputed tables for distribution and mass functions.

Detailed Description

Extends the class DiscreteDistributionInt for the discrete uniform distribution over the range \([i,j]\).

Its mass function is given by

\[ p(x) = \frac{1}{j - i + 1} \qquad\mbox{ for } x = i, i + 1, …, j \tag{fmassuniformint} \]

and 0 elsewhere. The distribution function is

\[ F(x) = \left\{\begin{array}{ll} 0, & \mbox{ for } x < i \\ \displaystyle\frac{\lfloor x\rfloor-i+1}{j-i+1}, & \mbox{ for } i\le x < j \\ 1, & \mbox{ for } x \ge j. \end{array}\right. \tag{cdfuniformint} \]

and its inverse is

\[ F^{-1}(u) = i + \lfloor(j - i + 1)u\rfloor\qquad\mbox{for }0 \le u \le1. \tag{invuniformint} \]

Definition at line 46 of file UniformIntDist.java.

Constructor & Destructor Documentation

◆ UniformIntDist()

umontreal.ssj.probdist.UniformIntDist.UniformIntDist ( int i,
int j )

Constructs a discrete uniform distribution over the interval \([i,j]\).

Definition at line 53 of file UniformIntDist.java.

Member Function Documentation

◆ barF() [1/2]

double umontreal.ssj.probdist.UniformIntDist.barF ( int i,
int j,
int x )
static

Computes the discrete uniform complementary distribution function.

\(\bar{F}(x)\). WARNING: The complementary distribution function is defined as \(\bar{F}(x) = P[X \ge x]\).

Definition at line 119 of file UniformIntDist.java.

◆ barF() [2/2]

double umontreal.ssj.probdist.UniformIntDist.barF ( int x)

Returns \(\bar{F}(x)\), the complementary distribution function.

See the WARNING above. The default implementation returns 1.0 - cdf(x - 1), which is not accurate when \(F(x)\) is near 1.

Parameters
xvalue at which the complementary distribution function must be evaluated
Returns
the complementary distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 65 of file UniformIntDist.java.

◆ cdf() [1/2]

double umontreal.ssj.probdist.UniformIntDist.cdf ( int i,
int j,
int x )
static

Computes the discrete uniform distribution function defined in ( cdfuniformint ).

Definition at line 102 of file UniformIntDist.java.

◆ cdf() [2/2]

double umontreal.ssj.probdist.UniformIntDist.cdf ( int x)

Returns the distribution function \(F\) evaluated at \(x\) (see ( FDistDisc )).

Parameters
xvalue at which the distribution function must be evaluated
Returns
the distribution function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 61 of file UniformIntDist.java.

◆ getI()

int umontreal.ssj.probdist.UniformIntDist.getI ( )

Returns the parameter \(i\).

Definition at line 236 of file UniformIntDist.java.

◆ getInstanceFromMLE()

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

Creates a new instance of a discrete uniform distribution over integers with parameters \(i\) and \(j\) estimated using the maximum likelihood method based on the \(n\) observations.

\(x[k]\), \(k = 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 190 of file UniformIntDist.java.

◆ getJ()

int umontreal.ssj.probdist.UniformIntDist.getJ ( )

Returns the parameter \(j\).

Definition at line 243 of file UniformIntDist.java.

◆ getMean() [1/2]

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

Returns the mean of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 73 of file UniformIntDist.java.

◆ getMean() [2/2]

double umontreal.ssj.probdist.UniformIntDist.getMean ( int i,
int j )
static

Computes and returns the mean \(E[X] = (i + j)/2\) of the discrete uniform distribution.

Returns
the mean of the discrete uniform distribution

Definition at line 203 of file UniformIntDist.java.

◆ getMLE()

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

Estimates the parameters \((i, j)\) of the uniform distribution over integers using the maximum likelihood method, from the \(n\) observations \(x[k]\), \(k = 0, 1, …, n-1\).

The estimates are returned in a two-element array, in regular order: [ \(i\), \(j\)]. The maximum likelihood estimators are the values

\((\hat{\imath}\), \(\hat{\jmath})\) that satisfy the equations

\begin{align*} \hat{\imath} & = \mbox{min} \{x_k\} \\ \hat{\jmath} & = \mbox{max} \{x_k\} \end{align*}

where \(\bar{x}_n\) is the average of \(x[0],…,x[n-1]\).

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

Definition at line 165 of file UniformIntDist.java.

◆ getParams()

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

Return a table containing the parameters of the current distribution.

This table is put in regular order: [ \(i\), \(j\)].

Implements umontreal.ssj.probdist.Distribution.

Definition at line 262 of file UniformIntDist.java.

◆ getStandardDeviation() [1/2]

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

Returns the standard deviation of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 81 of file UniformIntDist.java.

◆ getStandardDeviation() [2/2]

double umontreal.ssj.probdist.UniformIntDist.getStandardDeviation ( int i,
int j )
static

Computes and returns the standard deviation of the discrete uniform distribution.

Returns
the standard deviation of the discrete uniform distribution

Definition at line 229 of file UniformIntDist.java.

◆ getVariance() [1/2]

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

Returns the variance of the distribution function.

Implements umontreal.ssj.probdist.Distribution.

Definition at line 77 of file UniformIntDist.java.

◆ getVariance() [2/2]

double umontreal.ssj.probdist.UniformIntDist.getVariance ( int i,
int j )
static

Computes and returns the variance \(\mbox{Var}[X] = [(j - i + 1)^2 - 1]/{12}\) of the discrete uniform distribution.

Returns
the variance of the discrete uniform distribution

Definition at line 216 of file UniformIntDist.java.

◆ inverseF()

int umontreal.ssj.probdist.UniformIntDist.inverseF ( int i,
int j,
double u )
static

Computes the inverse of the discrete uniform distribution function ( invuniformint ).

Definition at line 134 of file UniformIntDist.java.

◆ inverseFInt()

int umontreal.ssj.probdist.UniformIntDist.inverseFInt ( double u)

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

\(0\le u\le1\). The default implementation uses binary search.

Parameters
uvalue in the interval \((0,1)\) for 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)\)
ArithmeticExceptionif the inverse cannot be computed, for example if it would give infinity in a theoritical context

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 69 of file UniformIntDist.java.

◆ prob() [1/2]

double umontreal.ssj.probdist.UniformIntDist.prob ( int i,
int j,
int x )
static

Computes the discrete uniform probability \(p(x)\) defined in ( fmassuniformint ).

Definition at line 89 of file UniformIntDist.java.

◆ prob() [2/2]

double umontreal.ssj.probdist.UniformIntDist.prob ( int x)

Returns \(p(x)\), the probability of \(x\).

Parameters
xvalue at which the mass function must be evaluated
Returns
the mass function evaluated at x

Reimplemented from umontreal.ssj.probdist.DiscreteDistributionInt.

Definition at line 57 of file UniformIntDist.java.

◆ setParams()

void umontreal.ssj.probdist.UniformIntDist.setParams ( int i,
int j )

Sets the parameters \(i\) and \(j\) for this object.

Definition at line 250 of file UniformIntDist.java.

◆ toString()

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

Returns a String containing information about the current distribution.

Reimplemented in umontreal.ssj.probdist.ConstantIntDist.

Definition at line 270 of file UniformIntDist.java.


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