Class AbstractContinuousDistribution

java.lang.Object
org.apache.commons.math.distribution.AbstractDistribution
org.apache.commons.math.distribution.AbstractContinuousDistribution
All Implemented Interfaces:
Serializable, ContinuousDistribution, Distribution
Direct Known Subclasses:
BetaDistributionImpl, CauchyDistributionImpl, ChiSquaredDistributionImpl, ExponentialDistributionImpl, FDistributionImpl, GammaDistributionImpl, NormalDistributionImpl, TDistributionImpl, WeibullDistributionImpl

public abstract class AbstractContinuousDistribution extends AbstractDistribution implements ContinuousDistribution, Serializable
Base class for continuous distributions. Default implementations are provided for some of the methods that do not vary from distribution to distribution.
See Also:
  • Method Details

    • density

      public double density(double x) throws MathRuntimeException
      Return the probability density for a particular point.
      Parameters:
      x - The point at which the density should be computed.
      Returns:
      The pdf at point x.
      Throws:
      MathRuntimeException - if the specialized class hasn't implemented this function
      Since:
      2.1
    • inverseCumulativeProbability

      public double inverseCumulativeProbability(double p) throws MathException
      For this distribution, X, this method returns the critical point x, such that P(X < x) = p.
      Specified by:
      inverseCumulativeProbability in interface ContinuousDistribution
      Parameters:
      p - the desired probability
      Returns:
      x, such that P(X < x) = p
      Throws:
      MathException - if the inverse cumulative probability can not be computed due to convergence or other numerical errors.
      IllegalArgumentException - if p is not a valid probability.
    • reseedRandomGenerator

      public void reseedRandomGenerator(long seed)
      Reseeds the random generator used to generate samples.
      Parameters:
      seed - the new seed
      Since:
      2.2
    • sample

      public double sample() throws MathException
      Generates a random value sampled from this distribution. The default implementation uses the inversion method.
      Returns:
      random value
      Throws:
      MathException - if an error occurs generating the random value
      Since:
      2.2
    • sample

      public double[] sample(int sampleSize) throws MathException
      Generates a random sample from the distribution. The default implementation generates the sample by calling sample() in a loop.
      Parameters:
      sampleSize - number of random values to generate
      Returns:
      an array representing the random sample
      Throws:
      MathException - if an error occurs generating the sample
      IllegalArgumentException - if sampleSize is not positive
      Since:
      2.2