|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.CustomDistribution
public class CustomDistribution
This class is used to generate random numbers from a probability density
function (PDF) defined as a number of pairs (value,rate) with possible
interpolation. You can supply the value and rate arrays directly, or
construct a distribution from a TableFunction. Each draw requires a random
number generator, so there are two different modes the CustomDistribution
can work:
1. You do not provide the RNG in the constructor, but supply it each time you
call get( Random ). In this case the CustomDistribution can safely be made
static and shared across multiple models and objects.
2. You provide the RNG in the constructor, the RNG is then remembered in the
CustomDistribution and you can use get() method without any parameters.
This is simpler syntax, but such CustomDistribution cannot be shared between
models with different RNGs used. The get( Random ) method can still be used
in that case.
| Field Summary | |
|---|---|
static int |
INTERPOLATION_LINEAR
|
static int |
INTERPOLATION_NONE
|
static int |
INTERPOLATION_STEP
|
| Constructor Summary | |
|---|---|
CustomDistribution(double[] observations)
Constructs a custom empirical distribution from the given array of observations. |
|
CustomDistribution(double[] values,
double[] rates,
int interpolationtype)
Constructs a custom distribution from the given arrays of values and rates, and a given interpolation type. |
|
CustomDistribution(double[] values,
double[] rates,
int interpolationtype,
java.util.Random rng)
Constructs a custom distribution from the given arrays of values and rates, and a given interpolation type. |
|
CustomDistribution(double[] intervalStarts,
int[] numberOfObservations)
Constructs a custom empirical distribution from the given arrays of interval starts and number of observations found in the corresponding intervals. |
|
CustomDistribution(double[] intervalStarts,
int[] numberOfObservations,
java.util.Random rng)
Constructs a custom empirical distribution from the given arrays of interval starts and number of observations found in the corresponding intervals. |
|
CustomDistribution(double[] observations,
java.util.Random rng)
Constructs a custom empirical distribution from the given array of observations. |
|
CustomDistribution(int[] observations)
Constructs a custom discrete empirical distribution from the given array of discrete observations. |
|
CustomDistribution(int[] observations,
java.util.Random rng)
Constructs a custom discrete empirical distribution from the given array of discrete observations. |
|
CustomDistribution(TableFunction table)
Constructs a custom distribution from a given TableFunction. |
|
CustomDistribution(TableFunction table,
java.util.Random rng)
Constructs a custom distribution from a given TableFunction. |
|
| Method Summary | |
|---|---|
double |
get()
Returns a random value distributed according to the given table of (value,rate) pairs. |
double |
get(double min,
double max,
double shift,
double stretch)
Generates a sample of truncated custom distribution. |
double |
get(double min,
double max,
double shift,
double stretch,
java.util.Random rng)
Generates a sample of truncated custom distribution. |
double |
get(java.util.Random rng)
Returns a random value distributed according to the given table of (value,rate) pairs. |
java.lang.String |
toString()
Returns the textual representation of the custom distribution. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int INTERPOLATION_NONE
public static final int INTERPOLATION_STEP
public static final int INTERPOLATION_LINEAR
| Constructor Detail |
|---|
public CustomDistribution(double[] intervalStarts,
int[] numberOfObservations)
intervalStarts - the array of interval starts (2 or more, no duplicates, can be sorted or not),
the last number is the end of the last intervalnumberOfObservations - the array of observation counters (same size as values, no negative rates),
the last number isn't actually used, it is assumed to be zero.
public CustomDistribution(double[] intervalStarts,
int[] numberOfObservations,
java.util.Random rng)
intervalStarts - the array of interval starts (2 or more, no duplicates, can be sorted or not),
the last number is the end of the last intervalnumberOfObservations - the array of observation counters (same size as values, no negative rates),
the last number isn't actually used, it is assumed to be zero.rng - the random number generator that will be used
public CustomDistribution(double[] values,
double[] rates,
int interpolationtype)
values - the array of values (2 or more, no duplicates, can be sorted or not)rates - the array of probability rates (same size as values, no negative rates)interpolationtype - the interpolation type: INTERPOLATION_NONE, INTERPOLATION_STEP, or INTERPOLATION_LINEARpublic CustomDistribution(TableFunction table)
table - the table function
public CustomDistribution(double[] values,
double[] rates,
int interpolationtype,
java.util.Random rng)
values - the array of values (2 or more, no duplicates, can be sorted or not)rates - the array of probability rates (same size as values, no negative rates)interpolationtype - the interpolation type: INTERPOLATION_NONE, INTERPOLATION_STEP, or INTERPOLATION_LINEARrng - the random number generator that will be used
public CustomDistribution(TableFunction table,
java.util.Random rng)
table - the table functionrng - the random number generator that will be usedpublic CustomDistribution(double[] observations)
observations - the array of observed values (at least one value, can be sorted or not)
public CustomDistribution(double[] observations,
java.util.Random rng)
observations - the array of observed values (at least one value, can be sorted or not)rng - the random number generator that will be usedpublic CustomDistribution(int[] observations)
observations - the array of observed values (at least one value, can be sorted or not)
public CustomDistribution(int[] observations,
java.util.Random rng)
observations - the array of observed values (at least one value, can be sorted or not)| Method Detail |
|---|
public double get(java.util.Random rng)
rng - the random number generator to be used.
public double get()
public double get(double min,
double max,
double shift,
double stretch,
java.util.Random rng)
sketch coefficient,
then shifted to the right by shift, after that it is
truncated to fit in [min, max] interval.
Truncation is performed by discarding
every sample outside this interval and taking subsequent try.get(Random)
min - the minimum value that this function will return.
The distribution is truncated to return values above this.
If the sample (stretched and shifted) is below this value
it will be discarded and another sample will be drawn.
Use Double.NEGATIVE_INFINITY for "No limit".max - the maximum value that this function will return.
The distribution is truncated to return values below this.
If the sample (stretched and shifted) is bigger than this value
it will be discarded and another sample will be drawn.
Use Double.POSITIVE_INFINITY for "No limit".shift - the shift parameter that indicates how much the
(stretched) distribution will shifted to the rightstretch - the stretch parameter that indicates how much the
distribution will be stretchedrng - the random number generator.
public double get(double min,
double max,
double shift,
double stretch)
sketch coefficient,
then shifted to the right by shift, after that it is
truncated to fit in [min, max] interval.
Truncation is performed by discarding
every sample outside this interval and taking subsequent try.get()
min - the minimum value that this function will return.
The distribution is truncated to return values above this.
If the sample (stretched and shifted) is below this value
it will be discarded and another sample will be drawn.
Use Double.NEGATIVE_INFINITY for "No limit".max - the maximum value that this function will return.
The distribution is truncated to return values below this.
If the sample (stretched and shifted) is bigger than this value
it will be discarded and another sample will be drawn.
Use Double.POSITIVE_INFINITY for "No limit".shift - the shift parameter that indicates how much the
(stretched) distribution will shifted to the rightstretch - the stretch parameter that indicates how much the
distribution will be stretched
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||