/** * Constructs an Empirical distribution. The probability distribution * function (pdf) is an array of positive real numbers. It need not be * provided in the form of relative probabilities, absolute probabilities * are also accepted. The <tt>pdf</tt> must satisfy both of the following * conditions * <ul> * <li><tt>0.0 <= pdf[i] : 0<=i<=pdf.length-1</tt> * <li><tt>0.0 < Sum(pdf[i]) : 0<=i<=pdf.length-1</tt> * </ul> * * @param pdf * the probability distribution function. * @param interpolationType * can be either <tt>Empirical.NO_INTERPOLATION</tt> or * <tt>Empirical.LINEAR_INTERPOLATION</tt>. * @param randomGenerator * a uniform random number generator. * @throws IllegalArgumentException * if at least one of the three conditions above is violated. */ public Empirical(double[] pdf, int interpolationType, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(pdf, interpolationType); }

/** * Constructs an Empirical distribution. The probability distribution * function (pdf) is an array of positive real numbers. It need not be * provided in the form of relative probabilities, absolute probabilities * are also accepted. The <tt>pdf</tt> must satisfy both of the following * conditions * <ul> * <li><tt>0.0 <= pdf[i] : 0<=i<=pdf.length-1</tt> * <li><tt>0.0 < Sum(pdf[i]) : 0<=i<=pdf.length-1</tt> * </ul> * * @param pdf * the probability distribution function. * @param interpolationType * can be either <tt>Empirical.NO_INTERPOLATION</tt> or * <tt>Empirical.LINEAR_INTERPOLATION</tt>. * @param randomGenerator * a uniform random number generator. * @throws IllegalArgumentException * if at least one of the three conditions above is violated. */ public Empirical(double[] pdf, int interpolationType, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(pdf, interpolationType); }

## Javadoc

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. If interpolationType == NO_INTERPOLATION no interpolation is performed and the result is a discrete distribution.

Instance methods operate on a user supplied uniform random number generator; they are unsynchronized. Static methods operate on a default uniform random number generator; they are synchronized.

**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++).

## Most used methods

- setRandomGenerator
- setStateSets the distribution parameters. The pdf must satisfy both of the following conditions * 0.0 <= pdf

## Popular in Java

- Running tasks concurrently on multiple threads
- onCreateOptionsMenu (Activity)
- getSharedPreferences (Context)
- getSystemService (Context)
- String (java.lang)
- NumberFormat (java.text)The abstract base class for all number formats. This class provides the interface for formatting and
- Calendar (java.util)Calendar is an abstract base class for converting between a Date object and a set of integer fields
- Reference (javax.naming)
- JTable (javax.swing)
- XPath (javax.xml.xpath)XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
- Github Copilot alternatives