Class DistributionFrequencies
java.lang.Object
nl.tudelft.simulation.jstats.distributions.empirical.DistributionFrequencies
DistributionFrequencies is a helper class to instantiate interpolated and non-interpolated distributions based on a given
array or list of values and corresponding frequencies (integer valued) or weights (real valued).
Copyright (c) 2021-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
- Author:
- Alexander Verbraeck
-
Method Summary
Modifier and TypeMethodDescriptioncreateDiscreteDistribution
(double[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.createDiscreteDistribution
(double[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(double[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(long[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.createDiscreteDistribution
(long[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(long[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(Number[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.createDiscreteDistribution
(Number[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(Number[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.createDiscreteDistribution
(Number[] values, Number[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.createDiscreteDistribution
(List<? extends Number> values, List<? extends Number> frequencies) Create a discrete empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding frequencies or weights.createDiscreteDistribution
(SortedMap<? extends Number, ? extends Number> frequenciesMap) Create a discrete empirical distribution based on a sorted map with sorted values mapping to frequencies.
-
Method Details
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(Number[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- Number[] the valuesfrequencies
- long[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(double[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- double[] the valuesfrequencies
- long[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(long[] values, long[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- long[] the valuesfrequencies
- long[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(Number[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- Number[] the valuesfrequencies
- int[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(double[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- double[] the valuesfrequencies
- int[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(long[] values, int[] frequencies) Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding values.- Parameters:
values
- long[] the valuesfrequencies
- int[]; the frequencies for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or frequencies array is null, or when one of the values is nullIllegalArgumentException
- when frequencies array or values array are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(List<? extends Number> values, List<? extends Number> frequencies) Create a discrete empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding frequencies or weights.- Parameters:
values
- List<? extends Number>; the valuesfrequencies
- List<? extends Number>; the frequencies or weights for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution lists
- Throws:
NullPointerException
- when frequencies list is null or values list is null, or when one of the values is nullIllegalArgumentException
- when frequencies list or values list are empty, or have unequal length, or when frequencies are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(SortedMap<? extends Number, ? extends Number> frequenciesMap) Create a discrete empirical distribution based on a sorted map with sorted values mapping to frequencies.- Parameters:
frequenciesMap
- SortedMap<? extends Number, ? extends Number>; the map with the entries- Returns:
- the cumulative distribution object belonging to the given distribution map
- Throws:
NullPointerException
- when frequencies map is null, or when one of the values or frequencies is nullIllegalArgumentException
- when frequencies map is empty, or when frequencies are not between 0 and 1, or when the sum of the probability frequencies is not 1.0
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(Number[] values, Number[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.- Parameters:
values
- Number[] the valuesweights
- Number[]; the weights for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or weights array is null, or when one of the values is nullIllegalArgumentException
- when weights array or values array are empty, or have unequal length, or when weights are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(Number[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.- Parameters:
values
- Number[] the valuesweights
- double[]; the weights for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or weights array is null, or when one of the values is nullIllegalArgumentException
- when weights array or values array are empty, or have unequal length, or when weights are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(double[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.- Parameters:
values
- double[] the valuesweights
- int[]; the weights for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or weights array is null, or when one of the values is nullIllegalArgumentException
- when weights array or values array are empty, or have unequal length, or when weights are zero or negative, or when values are not in ascending order
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(long[] values, double[] weights) Create a discrete empirical distribution from two arrays, one with weights, and one with corresponding values.- Parameters:
values
- long[] the valuesweights
- int[]; the weights for the corresponding values- Returns:
- the cumulative distribution object belonging to the given arrays
- Throws:
NullPointerException
- when values array is null or weights array is null, or when one of the values is nullIllegalArgumentException
- when weights array or values array are empty, or have unequal length, or when weights are zero or negative, or when values are not in ascending order
-