AnyLogic
Expand
Font size
All Implemented Interfaces:
Serializable

public class CustomDistributionContinuous
extends CustomDistributionAbstract<Double>
implements Serializable
This class is used to generate random numbers from a probability density function (PDF) defined as: - piecewise linear function. Piecewise linear function is defined by values and corresponding weights. - set of ranges with corresponding weights - set of samples Despite that this function defined with discrete number of values, it has continuous nature.
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
CustomDistributionContinuous(double[] samples)
Constructs a custom empirical distribution from array with occurrences.
CustomDistributionContinuous(double[] values, double[] weights)
Constructs a custom distribution from the given arrays of values and weights.
CustomDistributionContinuous(double[] starts, double[] ends, double[] weights)
Constructs a custom distribution from the given arrays of starts, ends and weights.
The distribution for the intersect ranges has no sense, thus each range shouldn't intersect with other ranges.
CustomDistributionContinuous(double[] starts, double[] ends, double[] weights, Random random)
Constructs a custom distribution from the given arrays of starts, ends and weights.
The distribution for the intersect ranges has no sense, thus each range shouldn't intersect with other ranges.
CustomDistributionContinuous(double[] values, double[] weights, Random random)
Constructs a custom distribution from the given arrays of points and rates.
CustomDistributionContinuous(double[] samples, Random random)
Constructs a custom empirical distribution from array with occurrences.

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

CustomDistributionContinuous

public CustomDistributionContinuous(double[] values,
 double[] weights)
Constructs a custom distribution from the given arrays of values and weights. N values with weights will be converted into N-1 intervals, which define piecewise linear function for PDF.
Parameters:
values - the array of values (2 or more, no duplicates)
weights - the array of weights (same size as weights, no negative values)

CustomDistributionContinuous

public CustomDistributionContinuous(double[] values,
 double[] weights,
 Random random)
Constructs a custom distribution from the given arrays of points and rates. N points with rates will be converted into N-1 intervals, which define piecewise linear function for PDF.
Parameters:
values - the array of values (2 or more, no duplicates)
weights - the array of weights (same size as values, no negative values)
random - random number generator

CustomDistributionContinuous

public CustomDistributionContinuous(double[] starts,
 double[] ends,
 double[] weights,
 Random random)
Constructs a custom distribution from the given arrays of starts, ends and weights.
The distribution for the intersect ranges has no sense, thus each range shouldn't intersect with other ranges. But the end of the one range could be the beginning of another. For example, ranges [0; 2] and [2; 3] are valid, whereas [0; 2] and [1; 3] are not.
Parameters:
starts - the array of ranges starts (1 or more)
ends - the array of ranges ends (same size as starts, each end should be bigger than start)
weights - the array of ranges weights (same size as starts, no negative weights)
random - random number generator

CustomDistributionContinuous

public CustomDistributionContinuous(double[] starts,
 double[] ends,
 double[] weights)
Constructs a custom distribution from the given arrays of starts, ends and weights.
The distribution for the intersect ranges has no sense, thus each range shouldn't intersect with other ranges. But the end of the one range could be the beginning of another. For example, ranges [0; 2] and [2; 3] are valid, whereas [0; 2] and [1; 3] are not.
Parameters:
starts - the array of ranges starts (1 or more)
ends - the array of ranges ends (same size as starts, each end should be bigger than start)
weights - the array of ranges weights (same size as starts, no negative weights)

CustomDistributionContinuous

public CustomDistributionContinuous(double[] samples,
 Random random)
Constructs a custom empirical distribution from array with occurrences.
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

CustomDistributionContinuous

public CustomDistributionContinuous(double[] samples)
Constructs a custom empirical distribution from array with occurrences.
Parameters:
samples - the array of values (non empty, may contain same values and the order of the values does not matter)

Method Details

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

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