Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.probdist
Class DiscreteDistribution

    java.lang.Object
      umontreal.iro.lecuyer.probdist.DiscreteDistribution

All Implemented Interfaces:
  Distribution

Direct Known Subclasses:
  EmpiricalDist

    public class DiscreteDistribution

extends Object
implements Distribution

Classes implementing discrete distributions over a finite set of real numbers should inherit from this class. For discrete distributions over integers, see `DiscreteDistributionInt`.

We assume that the random variable X of interest can take one of the n values x0 < ... < xn-1 (which are sorted by increasing order). It takes 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.

Note that the default implementation of the complementary distribution function returns `1.0 - cdf(x - 1)`, which is not accurate when F(x) is near 1.

Constructor Summary
`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.
`DiscreteDistribution(double[] obs, double[] prob, int n)` Constructs a discrete distribution over the n values contained in array `obs`, with probabilities given in array `prob`.
`DiscreteDistribution(int n, double[] obs, double[] prob)` Deprecated.

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] = ∑i=1npixi of the distribution.
`double[]` | `getParams()` Returns a table containing the parameters of the current distribution.
`double` | `getStandardDeviation()` Computes the standard deviation of the distribution.
`double` | `getVariance()` Computes the variance Var[X] = ∑i=1npi(xi - E[X])2 of the distribution.
`double` | `inverseF(double u)` Returns the inverse distribution function F-1(u), defined in.
`double` | `prob(int k)` Returns pk, the probability of the k-th observation, for 0 <= k < 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[] obs,
                                double[] prob,
                                int n)

  Constructs a discrete distribution over the n values contained in array `obs`, with probabilities given in array `prob`. Both arrays must have at least n elements, the probabilities must sum to 1, and the observations are assumed to be sorted by increasing order.

### DiscreteDistribution

    @Deprecated
    public DiscreteDistribution(int n,
                                           double[] obs,
                                           double[] prob)

  Deprecated.

  Same as `DiscreteDistribution(obs, prob, n)`.

### DiscreteDistribution

    public 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 observation values, and the last n values of `params` are the probabilities values.

Method Detail

### prob

    public double prob(int k)

  Returns pk, the probability of the k-th observation, for 0 <= k < n. The result should be a real number in the interval [0, 1].

  Parameters:
    `k` - observation number, 0 <= k < n
  Returns:
    the probability of observation `k`

### 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 must be 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 must be 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] = ∑i=1npixi of the distribution.

  Specified by:
    `getMean` in interface `Distribution`

### getVariance

    public double getVariance()

  Computes the variance Var[X] = ∑i=1npi(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`

### toString

    public String toString()

  Returns a `String` containing information about the current distribution.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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