SSJ  3.2.1
Stochastic Simulation in Java
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
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 DiscreteDistribution:
[legend]
Collaboration diagram for DiscreteDistribution:
[legend]

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. More...
 
 DiscreteDistribution (int[] values, double[] prob, int n)
 Similar to DiscreteDistribution(double[], double[], int).
 
 DiscreteDistribution (double[] params)
 Constructs a discrete distribution whose parameters are given in a single ordered array: params[0] contains \(n\), the number of values to consider. More...
 
double cdf (double x)
 Returns the distribution function \(F(x)\). More...
 
double barF (double x)
 
double inverseF (double u)
 
double getMean ()
 
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. More...
 
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 \(0\le i<n\). More...
 
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. More...
 
double getXsup ()
 Returns the upper limit \(x_{n-1}\) of the support of the distribution. More...
 
String toString ()
 Returns a String containing information about the current distribution.
 

Protected Attributes

double cdf [] = null
 
double pr [] = null
 
int xmin = 0
 
int xmax = 0
 
int xmed = 0
 
int nVal
 
double sortedVal []
 
double supportA = Double.NEGATIVE_INFINITY
 
double supportB = Double.POSITIVE_INFINITY
 

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.

Constructor & Destructor Documentation

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.

DiscreteDistribution ( double[]  params)

Constructs a discrete distribution whose parameters are given in a single ordered array: params[0] contains \(n\), the number of values to consider.

Then the next \(n\) values of params are the values \(x_j\), and the last \(n\) values of params are the probabilities \(p_j\).

Member Function Documentation

double barF ( double  x)
Parameters
xvalue at which the distribution function is evaluated
Returns
the distribution function evaluated at x

Implements Distribution.

double 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 Distribution.

double getMean ( )
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

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

Implements Distribution.

double [] 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 Distribution.

double getXinf ( )

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

Returns
\(x\) lower limit of support
double getXsup ( )

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

Returns
\(x\) upper limit of support
double inverseF ( double  u)
Parameters
xvalue at which the complementary distribution function is evaluated
Returns
the complementary distribution function evaluated at x

Implements Distribution.

double 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

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