This class implements discrete distributions over a finite set of real numbers (also over integers as a particular case). More...
Public Member Functions | |
| DiscreteDistribution (double[] values, double[] prob, int n) | |
| Constructs a discrete distribution over the \(n\) values contained in array values, with probabilities given in array prob. | |
| DiscreteDistribution (int[] values, double[] prob, int n) | |
Similar to DiscreteDistribution(double[], double[], int). | |
| double | cdf (double x) |
| double | barF (double x) |
| double | inverseF (double u) |
| double | getMean () |
| Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution. | |
| double | getVariance () |
| Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution. | |
| double | getStandardDeviation () |
| Computes the standard deviation of the distribution. | |
| double[] | getParams () |
| Returns a table containing the parameters of the current distribution. | |
| int | getN () |
| Returns the number of possible values \(x_i\). | |
| double | prob (int i) |
| Returns \(p_i\), the probability of the \(i\)-th value, for. | |
| double | getValue (int i) |
| Returns the \(i\)-th value \(x_i\), for \(0\le i<n\). | |
| double | getXinf () |
| Returns the lower limit \(x_0\) of the support of the distribution. | |
| double | getXsup () |
| Returns the upper limit \(x_{n-1}\) of the support of the distribution. | |
| String | toString () |
| Returns a String containing information about the current distribution. | |
This class implements discrete distributions over a finite set of real numbers (also over integers as a particular case).
We assume that the random variable \(X\) of interest can take one of the \(n\) values
\(x_0 < \cdots< x_{n-1}\), which must be sorted by increasing order. \(X\) can take the value \(x_k\) with probability \(p_k = P[X = x_k]\). In addition to the methods specified in the interface umontreal.ssj.probdist.Distribution, a method that returns the probability \(p_k\) is supplied.
Definition at line 45 of file DiscreteDistribution.java.
| umontreal.ssj.probdist.DiscreteDistribution.DiscreteDistribution | ( | double[] | values, |
| double[] | prob, | ||
| int | n ) |
Constructs a discrete distribution over the \(n\) values contained in array values, with probabilities given in array prob.
Both arrays must have at least \(n\) elements, the probabilities must sum to 1, and the values are assumed to be sorted by increasing order.
Definition at line 75 of file DiscreteDistribution.java.
| umontreal.ssj.probdist.DiscreteDistribution.DiscreteDistribution | ( | int[] | values, |
| double[] | prob, | ||
| int | n ) |
Similar to DiscreteDistribution(double[], double[], int).
Definition at line 83 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.barF | ( | double | x | ) |
| x | value at which the complementary distribution function is evaluated |
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 161 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.cdf | ( | double | x | ) |
| x | value at which the cdf is evaluated |
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 140 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getMean | ( | ) |
Computes the mean \(E[X] = \sum_i^{} p_i x_i\) of the distribution.
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.
Definition at line 241 of file DiscreteDistribution.java.
| int umontreal.ssj.probdist.DiscreteDistribution.getN | ( | ) |
Returns the number of possible values \(x_i\).
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 289 of file DiscreteDistribution.java.
| double[] umontreal.ssj.probdist.DiscreteDistribution.getParams | ( | ) |
Returns a table containing the parameters of the current distribution.
This table is built in regular order, according to constructor DiscreteDistribution(double[] params) order.
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 272 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getStandardDeviation | ( | ) |
Computes the standard deviation of the distribution.
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.
Definition at line 263 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getValue | ( | int | i | ) |
Returns the \(i\)-th value \(x_i\), for \(0\le i<n\).
Definition at line 309 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getVariance | ( | ) |
Computes the variance \(\mbox{Var}[X] = \sum_i^{} p_i (x_i - E[X])^2\) of the distribution.
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.
Definition at line 252 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getXinf | ( | ) |
Returns the lower limit \(x_0\) of the support of the distribution.
Definition at line 318 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.getXsup | ( | ) |
Returns the upper limit \(x_{n-1}\) of the support of the distribution.
Definition at line 327 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.inverseF | ( | double | u | ) |
| u | value in the interval \((0,1)\) for which the inverse distribution function is evaluated |
| IllegalArgumentException | if \(u\) is not in the interval \((0,1)\) |
| ArithmeticException | if the inverse cannot be computed, for example if it would give infinity in a theoretical context |
Implements umontreal.ssj.probdist.Distribution.
Reimplemented in umontreal.ssj.probdist.ConstantDist, and umontreal.ssj.probdist.EmpiricalDist.
Definition at line 190 of file DiscreteDistribution.java.
| double umontreal.ssj.probdist.DiscreteDistribution.prob | ( | int | i | ) |
Returns \(p_i\), the probability of the \(i\)-th value, for.
\(0\le i<n\).
| i | value number, \(0\le i < n\) |
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 300 of file DiscreteDistribution.java.
| String umontreal.ssj.probdist.DiscreteDistribution.toString | ( | ) |
Returns a String containing information about the current distribution.
Reimplemented in umontreal.ssj.probdist.EmpiricalDist.
Definition at line 334 of file DiscreteDistribution.java.