AnyLogic
Expand
Font size
All Implemented Interfaces:
Serializable

public class CustomDistributionOptions<E extends Enum<?>>
extends CustomDistributionAbstract<E>
implements Serializable
This class is used to generate random enum values 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 .
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

ConstructorDescription
CustomDistributionOptions(E[] values)
Constructs a custom empirical distribution from array with occurrences.
CustomDistributionOptions(E[] values, double[] weights)
Constructs a custom empirical distribution from arrays of values and weights.
CustomDistributionOptions(E[] values, double[] weights, Random random)
Constructs a custom empirical distribution from arrays of values and weights.
CustomDistributionOptions(E[] values, Random random)
Constructs a custom empirical distribution from array with occurrences.
CustomDistributionOptions(Map<E,Double> valuesWeightsMap)
Constructs a custom empirical distribution from the given map with values and weights.
CustomDistributionOptions(Map<E,Double> valuesWeightsMap, Random random)
Constructs a custom empirical distribution from the given map with values and weights.

Method Summary

Modifier and TypeMethodDescription
Eget(Random r)
Returns a random value according to distribution parameters and given random number generator.
intgetInt(Random r)
Returns a random integer, representing enum ordinal, according to distribution, if it is possible.

Methods inherited from class com.anylogic.engine.CustomDistributionAbstract

get, get, get, getInt, setRandom, toString

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Details

CustomDistributionOptions

public CustomDistributionOptions(Map<E,Double> valuesWeightsMap)
Constructs a custom empirical distribution from the given map with values and weights.
Parameters:
valuesWeightsMap - map with value, weight (non empty, no negative weights)

CustomDistributionOptions

public CustomDistributionOptions(Map<E,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

CustomDistributionOptions

public CustomDistributionOptions(E[] 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 duplicates
weights - the array of weights (same size as values, no negative weights)

CustomDistributionOptions

public CustomDistributionOptions(E[] 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 duplicates
weights - the array of weights (same size as values, no negative weights)
random - random number generator

CustomDistributionOptions

public CustomDistributionOptions(E[] values)
Constructs a custom empirical distribution from array with occurrences. Number of value occurrences defines the weight of the value.
Parameters:
values - the array of values (non empty, could repeat and be non sorted)

CustomDistributionOptions

public CustomDistributionOptions(E[] values,
 Random random)
Constructs a custom empirical distribution from array with occurrences. Number of value occurrences defines the weight of the value.
Parameters:
values - the array of values (non empty, could repeat and be non sorted)
random - random number generator

Method Details

getInt

public int getInt(Random r)
Returns a random integer, representing enum ordinal, according to distribution, if it is possible.
Specified by:
getInt in class CustomDistributionAbstract<E extends Enum<?>>
Parameters:
r - random number generator
Returns:
random integer from distribution

get

public E 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 class CustomDistributionAbstract<E>
Parameters:
r - random number generator
Returns:
random value from distribution