SSJ  3.3.1 Stochastic Simulation in Java
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).

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

## ◆ 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.

## ◆ barF()

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

Implements Distribution.

## ◆ cdf()

 double cdf ( double x )
Parameters
 x value at which the cdf is evaluated
Returns
the cdf evaluated at x

Implements Distribution.

## ◆ getParams()

 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.

## ◆ getXinf()

 double getXinf ( )

Returns the lower limit $$x_0$$ of the support of the distribution.

Returns
$$x$$ lower limit of support

## ◆ getXsup()

 double getXsup ( )

Returns the upper limit $$x_{n-1}$$ of the support of the distribution.

Returns
$$x$$ upper limit of support

## ◆ inverseF()

 double inverseF ( double u )
Parameters
 u value in the interval $$(0,1)$$ for which the inverse distribution function is evaluated
Returns
the inverse distribution function evaluated at u
Exceptions
 IllegalArgumentException if $$u$$ is not in the interval $$(0,1)$$ ArithmeticException if the inverse cannot be computed, for example if it would give infinity in a theoretical context

Implements Distribution.

## ◆ prob()

 double prob ( int i )

Returns $$p_i$$, the probability of the $$i$$-th value, for.

$$0\le i<n$$.

Parameters
 i value number, $$0\le i < n$$
Returns
the probability of value i

The documentation for this class was generated from the following file:
• DiscreteDistribution.java