- java.lang.Object
- com.anylogic.engine.CustomDistributionAbstract<E>
- com.anylogic.engine.CustomDistributionDiscrete
- All Implemented Interfaces:
Serializable
public class CustomDistributionDiscrete extends CustomDistributionAbstract<E> implements Serializable
This class is used to generate random numbers from a probability density
function (PDF) defined as a set of values of any type with corresponding rates.
You can supply the values and rates directly as a Map, as two lists with unique values and rates
or as a list with non-unique values.
For more information how to use get() function and set the random number generator see .
For more information how to use get() function and set the random number generator see .
- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
Constructor | Description |
---|---|
CustomDistributionDiscrete |
Constructs a custom empirical distribution from array with occurrences.
|
CustomDistributionDiscrete |
Constructs a custom empirical distribution from arrays of values and weights.
|
CustomDistributionDiscrete |
Constructs a custom empirical distribution from arrays of values and weights.
|
CustomDistributionDiscrete |
Constructs a custom empirical distribution from array with occurrences.
|
CustomDistributionDiscrete |
Constructs a custom empirical distribution from the given map with values and weights.
|
public CustomDistributionDiscrete(Map<Double, Double> valuesWeightsMap, Random random)
Constructs a custom empirical distribution from the given map with values and weights.
- Parameters:
valuesWeightsMap
- map with <value, weight> (non empty, no negative weights)random
- random number generator
public CustomDistributionDiscrete(double[] values, double[] weights)
Constructs a custom empirical distribution from arrays of values and weights.
- Parameters:
values
- the array of values (non empty, no duplicates) non-empty array with values without duplicatesweights
- the array of weights (same size as values, no negative weights)
public CustomDistributionDiscrete(double[] values, double[] weights, Random random)
Constructs a custom empirical distribution from arrays of values and weights.
- Parameters:
values
- the array of values (non empty, no duplicates) non-empty array with values without duplicatesweights
- the array of weights (same size as values, no negative weights)random
- random number generator
public CustomDistributionDiscrete(double[] samples)
Constructs a custom empirical distribution from array with occurrences.
Number of value occurrences defines the weight of the value.
- Parameters:
samples
- the array of values (non empty, may contain same values and the order of the values does not matter)
public CustomDistributionDiscrete(double[] samples, Random random)
Constructs a custom empirical distribution from array with occurrences.
Number of value occurrences defines the weight of the value.
- Parameters:
samples
- the array of values (non empty, may contain same values and the order of the values does not matter)random
- random number generator
public int getInt(Random r)
Description copied from class:
CustomDistributionAbstract
Returns a random integer according to distribution parameters, if possible.
- Specified by:
getInt
in classCustomDistributionAbstract<Double>
- Parameters:
r
- random number generator- Returns:
- random integer from distribution
public Double get(Random r)
Description copied from class:
CustomDistributionAbstract
Returns a random value according to distribution parameters and given random
number generator.
- Specified by:
get
in classCustomDistributionAbstract<E>
- Parameters:
r
- random number generator- Returns:
- random value from distribution