AnyLogic
Expand
Font size
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 .
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

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

Method Summary

Modifier and TypeMethodDescription
Doubleget(Random r)
Returns a random value according to distribution parameters and given random number generator.
intgetInt(Random r)
Returns a random integer according to distribution parameters, if 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

CustomDistributionDiscrete

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

CustomDistributionDiscrete

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

CustomDistributionDiscrete

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

CustomDistributionDiscrete

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)

CustomDistributionDiscrete

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

Method Details

getInt

public int getInt(Random r)
Description copied from class: CustomDistributionAbstract
Returns a random integer according to distribution parameters, if possible.
Specified by:
getInt in class CustomDistributionAbstract<Double>
Parameters:
r - random number generator
Returns:
random integer from distribution

get

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