public class Empirical extends AbstractContinousDoubleDistribution
The probability distribution function (pdf) must be provided by the user as an array of positive real numbers. The pdf does not need to be provided in the form of relative probabilities, absolute probabilities are also accepted.
If interpolationType == LINEAR_INTERPOLATION a linear interpolation within the bin is computed, resulting in a constant density within each bin.
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
Implementation: A uniform random number is generated using a user supplied generator. The uniform number is then transformed to the user's distribution using the cumulative probability distribution constructed from the pdf. The cumulative distribution is inverted using a binary search for the nearest bin boundary.
This is a port of RandGeneral used in CLHEP 1.4.0 (C++).
Modifier and Type | Field and Description |
---|---|
static int |
LINEAR_INTERPOLATION |
static int |
NO_INTERPOLATION |
Constructor and Description |
---|
Empirical(double[] pdf,
int interpolationType,
DoubleRandomEngine randomGenerator)
Constructs an Empirical distribution.
|
Modifier and Type | Method and Description |
---|---|
double |
cdf(int k)
Returns the cumulative distribution function.
|
Object |
clone()
Returns a deep copy of the receiver; the copy will produce identical
sequences.
|
double |
nextDouble()
Returns a random number from the distribution.
|
double |
pdf(double x)
Returns the probability distribution function.
|
double |
pdf(int k)
Returns the probability distribution function.
|
void |
setState(double[] pdf,
int interpolationType)
Sets the distribution parameters.
|
String |
toString()
Returns a String representation of the receiver.
|
apply, apply, makeDefaultGenerator, nextInt
public static final int LINEAR_INTERPOLATION
public static final int NO_INTERPOLATION
public Empirical(double[] pdf, int interpolationType, DoubleRandomEngine randomGenerator)
pdf
- the probability distribution function.interpolationType
- can be either Empirical.NO_INTERPOLATION or
Empirical.LINEAR_INTERPOLATION.randomGenerator
- a uniform random number generator.IllegalArgumentException
- if at least one of the three conditions above is violated.public double cdf(int k)
public Object clone()
clone
in class AbstractDoubleDistribution
public double nextDouble()
nextDouble
in class AbstractDoubleDistribution
public double pdf(double x)
public double pdf(int k)
public void setState(double[] pdf, int interpolationType)
pdf
- probability distribution function.interpolationType
- can be either Empirical.NO_INTERPOLATION or
Empirical.LINEAR_INTERPOLATION.IllegalArgumentException
- if at least one of the three conditions above is violated.Jump to the Parallel Colt Homepage