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

This class implements discrete distributions over a finite set of real numbers (also over integers as a particular case). More...

Inheritance diagram for umontreal.ssj.probdist.DiscreteDistribution:
umontreal.ssj.probdist.Distribution umontreal.ssj.probdist.ConstantDist umontreal.ssj.probdist.EmpiricalDist

Public Member Functions

 DiscreteDistribution (double[] values, double[] prob, int n)
 Constructs a discrete distribution over the \(n\) values contained in array values, with probabilities given in array prob.
 DiscreteDistribution (int[] values, double[] prob, int n)
 Similar to DiscreteDistribution(double[], double[], int).
double cdf (double x)
double barF (double x)
double inverseF (double u)
double getMean ()
 Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution.
double getVariance ()
 Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution.
double getStandardDeviation ()
 Computes the standard deviation of the distribution.
double[] getParams ()
 Returns a table containing the parameters of the current distribution.
int getN ()
 Returns the number of possible values \(x_i\).
double prob (int i)
 Returns \(p_i\), the probability of the \(i\)-th value, for.
double getValue (int i)
 Returns the \(i\)-th value \(x_i\), for \(0\le i<n\).
double getXinf ()
 Returns the lower limit \(x_0\) of the support of the distribution.
double getXsup ()
 Returns the upper limit \(x_{n-1}\) of the support of the distribution.
String toString ()
 Returns a String containing information about the current distribution.

Detailed Description

This class implements discrete distributions over a finite set of real numbers (also over integers as a particular case).

We assume that the random variable \(X\) of interest can take one of the \(n\) values

\(x_0 < \cdots< x_{n-1}\), which must be sorted by increasing order. \(X\) can take the value \(x_k\) with probability \(p_k = P[X = x_k]\). In addition to the methods specified in the interface umontreal.ssj.probdist.Distribution, a method that returns the probability \(p_k\) is supplied.

Definition at line 45 of file DiscreteDistribution.java.

Constructor & Destructor Documentation

◆ DiscreteDistribution() [1/2]

umontreal.ssj.probdist.DiscreteDistribution.DiscreteDistribution ( double[] values,
double[] prob,
int n )

Constructs a discrete distribution over the \(n\) values contained in array values, with probabilities given in array prob.

Both arrays must have at least \(n\) elements, the probabilities must sum to 1, and the values are assumed to be sorted by increasing order.

Definition at line 75 of file DiscreteDistribution.java.

◆ DiscreteDistribution() [2/2]

umontreal.ssj.probdist.DiscreteDistribution.DiscreteDistribution ( int[] values,
double[] prob,
int n )

Member Function Documentation

◆ barF()

double umontreal.ssj.probdist.DiscreteDistribution.barF ( double x)
Parameters
xvalue at which the complementary distribution function is evaluated
Returns
the complementary distribution function evaluated at x

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 161 of file DiscreteDistribution.java.

◆ cdf()

double umontreal.ssj.probdist.DiscreteDistribution.cdf ( double x)
Parameters
xvalue at which the cdf is evaluated
Returns
the cdf evaluated at x

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 140 of file DiscreteDistribution.java.

◆ getMean()

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

Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution.

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.

Definition at line 241 of file DiscreteDistribution.java.

◆ getN()

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

Returns the number of possible values \(x_i\).

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 289 of file DiscreteDistribution.java.

◆ getParams()

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

Returns a table containing the parameters of the current distribution.

This table is built in regular order, according to constructor DiscreteDistribution(double[] params) order.

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 272 of file DiscreteDistribution.java.

◆ getStandardDeviation()

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

Computes the standard deviation of the distribution.

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.

Definition at line 263 of file DiscreteDistribution.java.

◆ getValue()

double umontreal.ssj.probdist.DiscreteDistribution.getValue ( int i)

Returns the \(i\)-th value \(x_i\), for \(0\le i<n\).

Definition at line 309 of file DiscreteDistribution.java.

◆ getVariance()

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

Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution.

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.

Definition at line 252 of file DiscreteDistribution.java.

◆ getXinf()

double umontreal.ssj.probdist.DiscreteDistribution.getXinf ( )

Returns the lower limit \(x_0\) of the support of the distribution.

Returns
\(x\) lower limit of support

Definition at line 318 of file DiscreteDistribution.java.

◆ getXsup()

double umontreal.ssj.probdist.DiscreteDistribution.getXsup ( )

Returns the upper limit \(x_{n-1}\) of the support of the distribution.

Returns
\(x\) upper limit of support

Definition at line 327 of file DiscreteDistribution.java.

◆ inverseF()

double umontreal.ssj.probdist.DiscreteDistribution.inverseF ( double u)
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 theoretical context

Implements umontreal.ssj.probdist.Distribution.

Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.

Definition at line 190 of file DiscreteDistribution.java.

◆ prob()

double umontreal.ssj.probdist.DiscreteDistribution.prob ( int i)

Returns \(p_i\), the probability of the \(i\)-th value, for.

\(0\le i<n\).

Parameters
ivalue number, \(0\le i < n\)
Returns
the probability of value i

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 300 of file DiscreteDistribution.java.

◆ toString()

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

Returns a String containing information about the current distribution.

Reimplemented in umontreal.ssj.probdist.EmpiricalDist.

Definition at line 334 of file DiscreteDistribution.java.


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