SSJ
V. 2.6.

## umontreal.iro.lecuyer.probdist Class DiscreteDistribution

```java.lang.Object
umontreal.iro.lecuyer.probdist.DiscreteDistribution
```
All Implemented Interfaces:
Distribution
Direct Known Subclasses:
ConstantDist, EmpiricalDist

`public class DiscreteDistributionextends Objectimplements Distribution`

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 x0 < ... < xn-1, which must be sorted by increasing order. X can take the value xk with probability pk = P[X = xk]. In addition to the methods specified in the interface `Distribution`, a method that returns the probability pk is supplied.

Constructor Summary
`DiscreteDistribution(double[] params)`
Deprecated.
```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).

Method Summary
` double` `barF(double x)`
Returns bar(F)(x) = 1 - F(x).
` double` `cdf(double x)`
Returns the distribution function F(x).
` double` `getMean()`
Computes the mean E[X] = ∑ipixi of the distribution.
` int` `getN()`
Returns the number of possible values xi.
` double[]` `getParams()`
Returns a table containing the parameters of the current distribution.
` double` `getStandardDeviation()`
Computes the standard deviation of the distribution.
` double` `getValue(int i)`
Returns the i-th value xi, for 0 <= i < n.
` double` `getVariance()`
Computes the variance Var[X] = ∑ipi(xi - E[X])2 of the distribution.
` double` `getXinf()`
Returns the lower limit x0 of the support of the distribution.
` double` `getXsup()`
Returns the upper limit xn-1 of the support of the distribution.
` double` `inverseF(double u)`
Returns the inverse distribution function F-1(u), defined in.
` double` `prob(int i)`
Returns pi, the probability of the i-th value, for 0 <= i < n.
` String` `toString()`
Returns a String containing information about the current distribution.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DiscreteDistribution

```public 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

```public DiscreteDistribution(int[] values,
double[] prob,
int n)```
Similar to `DiscreteDistribution`(double[], double[], int).

### DiscreteDistribution

```@Deprecated
public DiscreteDistribution(double[] params)```
Deprecated.

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 xj, and the last n values of params are the probabilities pj.

Method Detail

### cdf

`public double cdf(double x)`
Description copied from interface: `Distribution`
Returns the distribution function F(x).

Specified by:
`cdf` in interface `Distribution`
Parameters:
`x` - value at which the distribution function is evaluated
Returns:
the distribution function evaluated at x

### barF

`public double barF(double x)`
Description copied from interface: `Distribution`
Returns bar(F)(x) = 1 - F(x).

Specified by:
`barF` in interface `Distribution`
Parameters:
`x` - value at which the complementary distribution function is evaluated
Returns:
the complementary distribution function evaluated at x

### inverseF

`public double inverseF(double u)`
Description copied from interface: `Distribution`
Returns the inverse distribution function F-1(u), defined in.

Specified by:
`inverseF` in interface `Distribution`
Parameters:
`u` - value in the interval (0, 1) for which the inverse distribution function is evaluated
Returns:
the inverse distribution function evaluated at u

### getMean

`public double getMean()`
Computes the mean E[X] = ∑ipixi of the distribution.

Specified by:
`getMean` in interface `Distribution`

### getVariance

`public double getVariance()`
Computes the variance Var[X] = ∑ipi(xi - E[X])2 of the distribution.

Specified by:
`getVariance` in interface `Distribution`

### getStandardDeviation

`public double getStandardDeviation()`
Computes the standard deviation of the distribution.

Specified by:
`getStandardDeviation` in interface `Distribution`

### getParams

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

Specified by:
`getParams` in interface `Distribution`

### getN

`public int getN()`
Returns the number of possible values xi.

### prob

`public double prob(int i)`
Returns pi, the probability of the i-th value, for 0 <= i < n.

Parameters:
`i` - value number, 0 <= i < n
Returns:
the probability of value i

### getValue

`public double getValue(int i)`
Returns the i-th value xi, for 0 <= i < n.

### getXinf

`public double getXinf()`
Returns the lower limit x0 of the support of the distribution.

Returns:
x lower limit of support

### getXsup

`public double getXsup()`
Returns the upper limit xn-1 of the support of the distribution.

Returns:
x upper limit of support

### toString

`public String toString()`
Returns a String containing information about the current distribution.

Overrides:
`toString` in class `Object`

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.