org.apache.commons.math3.distribution

## Class AbstractRealDistribution

- java.lang.Object
- - org.apache.commons.math3.distribution.AbstractRealDistribution

- All Implemented Interfaces:
    java.io.Serializable, RealDistribution
  Direct Known Subclasses:
    BetaDistribution, CauchyDistribution, ChiSquaredDistribution, EmpiricalDistribution, ExponentialDistribution, FDistribution, GammaDistribution, LogNormalDistribution, NormalDistribution, TDistribution, TriangularDistribution, UniformRealDistribution, WeibullDistribution

      public abstract class AbstractRealDistribution
      extends java.lang.Object
      implements RealDistribution, java.io.Serializable

  Base class for probability distributions on the reals. Default implementations are provided for some of the methods that do not vary from distribution to distribution.
  Since:
    3.0
  Version:
    $Id: AbstractRealDistribution.java 1422195 2012-12-15 06:45:18Z psteitz $
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RandomGenerator` | `random` RNG instance used to generate samples from the distribution.
    `protected RandomDataImpl` | `randomData` Deprecated. As of 3.1, to be removed in 4.0. Please use the `random` instance variable instead.
    `private static long` | `serialVersionUID` Serializable version identifier
    `static double` | `SOLVER_DEFAULT_ABSOLUTE_ACCURACY` Default accuracy.
    `private double` | `solverAbsoluteAccuracy` Solver absolute accuracy for inverse cumulative computation

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractRealDistribution()` Deprecated. As of 3.1, to be removed in 4.0. Please use `AbstractRealDistribution(RandomGenerator)` instead.
    `protected` | `AbstractRealDistribution(RandomGenerator rng)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `cumulativeProbability(double x0, double x1)` Deprecated. As of 3.1 (to be removed in 4.0). Please use `probability(double,double)` instead.
    `protected double` | `getSolverAbsoluteAccuracy()` Returns the solver absolute accuracy for inverse cumulative computation.
    `double` | `inverseCumulativeProbability(double p)` Computes the quantile function of this distribution.
    `double` | `probability(double x)` For a random variable `X` whose values are distributed according to this distribution, this method returns `P(X = x)`.
    `double` | `probability(double x0, double x1)` For a random variable `X` whose values are distributed according to this distribution, this method returns `P(x0 < X <= x1)`.
    `void` | `reseedRandomGenerator(long seed)` Reseed the random generator used to generate samples.
    `double` | `sample()` Generate a random value sampled from this distribution.
    `double[]` | `sample(int sampleSize)` Generate a random sample from the distribution.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.math3.distribution.RealDistribution

      `cumulativeProbability, density, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnected, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive`

- - ### Field Detail

    - #### SOLVER_DEFAULT_ABSOLUTE_ACCURACY

          public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY

      Default accuracy.
      See Also:
        Constant Field Values

    - #### serialVersionUID

          private static final long serialVersionUID

      Serializable version identifier
      See Also:
        Constant Field Values

    - #### randomData

          @Deprecated
          protected RandomDataImpl randomData

      Deprecated. As of 3.1, to be removed in 4.0. Please use the `random` instance variable instead.
      RandomData instance used to generate samples from the distribution.

    - #### random

          protected final RandomGenerator random

      RNG instance used to generate samples from the distribution.
      Since:
        3.1

    - #### solverAbsoluteAccuracy

          private double solverAbsoluteAccuracy

      Solver absolute accuracy for inverse cumulative computation

  - ### Constructor Detail

    - #### AbstractRealDistribution

          @Deprecated
          protected AbstractRealDistribution()

      Deprecated. As of 3.1, to be removed in 4.0. Please use `AbstractRealDistribution(RandomGenerator)` instead.

    - #### AbstractRealDistribution

          protected AbstractRealDistribution(RandomGenerator rng)

      Parameters:
        `rng` - Random number generator.
      Since:
        3.1

  - ### Method Detail

    - #### cumulativeProbability

          @Deprecated
          public double cumulativeProbability(double x0,
                                                double x1)
                                       throws NumberIsTooLargeException

      Deprecated. As of 3.1 (to be removed in 4.0). Please use `probability(double,double)` instead.
      For a random variable `X` whose values are distributed according to this distribution, this method returns `P(x0 < X <= x1)`. The default implementation uses the identity

      `P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)`

      Specified by:
        `cumulativeProbability` in interface `RealDistribution`
      Parameters:
        `x0` - the exclusive lower bound
        `x1` - the inclusive upper bound
      Returns:
        the probability that a random variable with this distribution takes a value between `x0` and `x1`, excluding the lower and including the upper endpoint
      Throws:
        `NumberIsTooLargeException` - if `x0 > x1`

    - #### probability

          public double probability(double x0,
                           double x1)

      For a random variable `X` whose values are distributed according to this distribution, this method returns `P(x0 < X <= x1)`.
      Parameters:
        `x0` - Lower bound (excluded).
        `x1` - Upper bound (included).
      Returns:
        the probability that a random variable with this distribution takes a value between `x0` and `x1`, excluding the lower and including the upper endpoint.
      Throws:
        `NumberIsTooLargeException` - if `x0 > x1`. The default implementation uses the identity `P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)`
      Since:
        3.1

    - #### inverseCumulativeProbability

          public double inverseCumulativeProbability(double p)
                                              throws OutOfRangeException

      Computes the quantile function of this distribution. For a random variable `X` distributed according to this distribution, the returned value is
      - `inf{x in R | P(X<=x) >= p}` for `0 < p <= 1`,
      - `inf{x in R | P(X<=x) > 0}` for `p = 0`.
      The default implementation returns
      - `RealDistribution.getSupportLowerBound()` for `p = 0`,
      - `RealDistribution.getSupportUpperBound()` for `p = 1`.
      Specified by:
        `inverseCumulativeProbability` in interface `RealDistribution`
      Parameters:
        `p` - the cumulative probability
      Returns:
        the smallest `p`-quantile of this distribution (largest 0-quantile for `p = 0`)
      Throws:
        `OutOfRangeException` - if `p < 0` or `p > 1`

    - #### getSolverAbsoluteAccuracy

          protected double getSolverAbsoluteAccuracy()

      Returns the solver absolute accuracy for inverse cumulative computation. You can override this method in order to use a Brent solver with an absolute accuracy different from the default.
      Returns:
        the maximum absolute error in inverse cumulative probability estimates

    - #### reseedRandomGenerator

          public void reseedRandomGenerator(long seed)

      Reseed the random generator used to generate samples.
      Specified by:
        `reseedRandomGenerator` in interface `RealDistribution`
      Parameters:
        `seed` - the new seed

    - #### sample

          public double sample()

      Generate a random value sampled from this distribution. The default implementation uses the inversion method.
      Specified by:
        `sample` in interface `RealDistribution`
      Returns:
        a random value.

    - #### sample

          public double[] sample(int sampleSize)

      Generate a random sample from the distribution. The default implementation generates the sample by calling `sample()` in a loop.
      Specified by:
        `sample` in interface `RealDistribution`
      Parameters:
        `sampleSize` - the number of random values to generate
      Returns:
        an array representing the random sample

    - #### probability

          public double probability(double x)

      For a random variable `X` whose values are distributed according to this distribution, this method returns `P(X = x)`. In other words, this method represents the probability mass function (PMF) for the distribution.
      Specified by:
        `probability` in interface `RealDistribution`
      Parameters:
        `x` - the point at which the PMF is evaluated
      Returns:
        zero.
      Since:
        3.1

Copyright (c) 2003-2013 Apache Software Foundation