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.
- Version:
- $Revision: 1073498 $ $Date: 2011-02-22 21:57:26 +0100 (mar. 22 févr. 2011) $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RandomDataImplRandomData instance used to generate samples from the distribution -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubledensity(double x) Return the probability density for a particular point.protected abstract doublegetDomainLowerBound(double p) Access the domain value lower bound, based onp, used to bracket a CDF root.protected abstract doublegetDomainUpperBound(double p) Access the domain value upper bound, based onp, used to bracket a CDF root.protected abstract doublegetInitialDomain(double p) Access the initial domain value, based onp, used to bracket a CDF root.protected doubleReturns the solver absolute accuracy for inverse cumulative computation.doubleinverseCumulativeProbability(double p) For this distribution, X, this method returns the critical point x, such that P(X < x) =p.voidreseedRandomGenerator(long seed) Reseeds the random generator used to generate samples.doublesample()Generates a random value sampled from this distribution.double[]sample(int sampleSize) Generates a random sample from the distribution.Methods inherited from class org.apache.commons.math.distribution.AbstractDistribution
cumulativeProbabilityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.math.distribution.Distribution
cumulativeProbability, cumulativeProbability
-
Field Details
-
randomData
RandomData instance used to generate samples from the distribution- Since:
- 2.2
-
-
Constructor Details
-
AbstractContinuousDistribution
protected AbstractContinuousDistribution()Default constructor.
-
-
Method Details
-
density
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
For this distribution, X, this method returns the critical point x, such that P(X < x) =p.- Specified by:
inverseCumulativeProbabilityin interfaceContinuousDistribution- 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- ifpis 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
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
Generates a random sample from the distribution. The default implementation generates the sample by callingsample()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 sampleIllegalArgumentException- if sampleSize is not positive- Since:
- 2.2
-
getInitialDomain
protected abstract double getInitialDomain(double p) Access the initial domain value, based onp, used to bracket a CDF root. This method is used byinverseCumulativeProbability(double)to find critical values.- Parameters:
p- the desired probability for the critical value- Returns:
- initial domain value
-
getDomainLowerBound
protected abstract double getDomainLowerBound(double p) Access the domain value lower bound, based onp, used to bracket a CDF root. This method is used byinverseCumulativeProbability(double)to find critical values.- Parameters:
p- the desired probability for the critical value- Returns:
- domain value lower bound, i.e.
P(X < lower bound) <
p
-
getDomainUpperBound
protected abstract double getDomainUpperBound(double p) Access the domain value upper bound, based onp, used to bracket a CDF root. This method is used byinverseCumulativeProbability(double)to find critical values.- Parameters:
p- the desired probability for the critical value- Returns:
- domain value upper bound, i.e.
P(X < upper bound) >
p
-
getSolverAbsoluteAccuracy
protected double getSolverAbsoluteAccuracy()Returns the solver absolute accuracy for inverse cumulative computation.- Returns:
- the maximum absolute error in inverse cumulative probability estimates
- Since:
- 2.1
-