SSJ
V. 2.6.

## umontreal.iro.lecuyer.probdist Class EmpiricalDist

```java.lang.Object
umontreal.iro.lecuyer.probdist.DiscreteDistribution
umontreal.iro.lecuyer.probdist.EmpiricalDist
```
All Implemented Interfaces:
Distribution

`public class EmpiricalDistextends DiscreteDistribution`

Extends `DiscreteDistribution` to an empirical distribution function, based on the observations X(1),..., X(n) (sorted by increasing order). The distribution is uniform over the n observations, so the distribution function has a jump of 1/n at each of the n observations.

Constructor Summary
`EmpiricalDist(double[] obs)`
Constructs a new empirical distribution using all the observations stored in obs, and which are assumed to have been sorted in increasing numerical order.
`EmpiricalDist(Reader in)`
Constructs a new empirical distribution using the observations read from the reader in.

Method Summary
` double` `barF(double x)`
Returns bar(F)(x) = 1 - F(x).
` double` `cdf(double x)`
Returns the distribution function F(x).
` double` `getInterQuartileRange()`
Returns the interquartile range of the observations, defined as the difference between the third and first quartiles.
` double` `getMean()`
Computes the mean E[X] = ∑ipixi of the distribution.
` double` `getMedian()`
Returns the median.
`static double` ```getMedian(double[] obs, int n)```
Returns the median.
` int` `getN()`
Returns n, the number of observations.
` double` `getObs(int i)`
Returns the value of X(i), for i = 0, 1,…, n - 1.
` double[]` `getParams()`
Return a table containing parameters of the current distribution.
` double` `getSampleMean()`
Returns the sample mean of the observations.
` double` `getSampleStandardDeviation()`
Returns the sample standard deviation of the observations.
` double` `getSampleVariance()`
Returns the sample variance of the observations.
` double` `getStandardDeviation()`
Computes the standard deviation of the distribution.
` double` `getVariance()`
Computes the variance Var[X] = ∑ipi(xi - E[X])2 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 umontreal.iro.lecuyer.probdist.DiscreteDistribution
`getValue, getXinf, getXsup`

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

Constructor Detail

### EmpiricalDist

`public EmpiricalDist(double[] obs)`
Constructs a new empirical distribution using all the observations stored in obs, and which are assumed to have been sorted in increasing numerical order. 1 These observations are copied into an internal array.

### EmpiricalDist

```public EmpiricalDist(Reader in)
throws IOException```
Constructs a new empirical distribution using the observations read from the reader in. This constructor will read the first double of each line in the stream. Any line that does not start with a +, -, or a decimal digit, is ignored. One must be careful about lines starting with a blank. This format is the same as in UNURAN. The observations read are assumed to have been sorted in increasing numerical order.

Throws:
`IOException`
Method Detail

### prob

`public double prob(int i)`
Description copied from class: `DiscreteDistribution`
Returns pi, the probability of the i-th value, for 0 <= i < n.

Overrides:
`prob` in class `DiscreteDistribution`
Parameters:
`i` - value number, 0 <= i < n
Returns:
the probability of value i

### cdf

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

Specified by:
`cdf` in interface `Distribution`
Overrides:
`cdf` in class `DiscreteDistribution`
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`
Overrides:
`barF` in class `DiscreteDistribution`
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`
Overrides:
`inverseF` in class `DiscreteDistribution`
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()`
Description copied from class: `DiscreteDistribution`
Computes the mean E[X] = ∑ipixi of the distribution.

Specified by:
`getMean` in interface `Distribution`
Overrides:
`getMean` in class `DiscreteDistribution`

### getStandardDeviation

`public double getStandardDeviation()`
Description copied from class: `DiscreteDistribution`
Computes the standard deviation of the distribution.

Specified by:
`getStandardDeviation` in interface `Distribution`
Overrides:
`getStandardDeviation` in class `DiscreteDistribution`

### getVariance

`public double getVariance()`
Description copied from class: `DiscreteDistribution`
Computes the variance Var[X] = ∑ipi(xi - E[X])2 of the distribution.

Specified by:
`getVariance` in interface `Distribution`
Overrides:
`getVariance` in class `DiscreteDistribution`

### getMedian

`public double getMedian()`
Returns the median. Returns the n/2th item of the sorted observations when the number of items is odd, and the mean of the n/2th and the (n/2 + 1)th items when the number of items is even.

### getMedian

```public static double getMedian(double[] obs,
int n)```
Returns the median. Returns the n/2th item of the array obs when the number of items is odd, and the mean of the n/2th and the (n/2 + 1)th items when the number of items is even. The array does not have to be sorted.

Parameters:
`obs` - the array of observations
`n` - the number of observations
Returns:
return the median of the observations

### getN

`public int getN()`
Returns n, the number of observations.

Overrides:
`getN` in class `DiscreteDistribution`

### getObs

`public double getObs(int i)`
Returns the value of X(i), for i = 0, 1,…, n - 1.

### getSampleMean

`public double getSampleMean()`
Returns the sample mean of the observations.

### getSampleVariance

`public double getSampleVariance()`
Returns the sample variance of the observations.

### getSampleStandardDeviation

`public double getSampleStandardDeviation()`
Returns the sample standard deviation of the observations.

### getInterQuartileRange

`public double getInterQuartileRange()`
Returns the interquartile range of the observations, defined as the difference between the third and first quartiles.

### getParams

`public double[] getParams()`
Return a table containing parameters of the current distribution.

Specified by:
`getParams` in interface `Distribution`
Overrides:
`getParams` in class `DiscreteDistribution`

### toString

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

Overrides:
`toString` in class `DiscreteDistribution`

SSJ
V. 2.6.

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