Class CumulativeProbabilities
java.lang.Object
nl.tudelft.simulation.jstats.distributions.empirical.CumulativeProbabilities
CumulativeProbabilities is a helper class to instantiate interpolated and non-interpolated distributions based on a given
array or list of values and corresponding cumulative probabilities.
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[] cumulativeProbabilities) Create an empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createDiscreteDistribution
(long[] values, double[] cumulativeProbabilities) Create a discrete empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createDiscreteDistribution
(Number[] values, double[] cumulativeProbabilities) Create a discrete empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createDiscreteDistribution
(List<? extends Number> values, List<Double> cumulativeProbabilities) Create a discrete empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createDiscreteDistribution
(SortedMap<? extends Number, Double> cumulativeProbabilitiesMap) Create a discrete empirical distribution based on a sorted map with sorted values mapping to cumulative probabilities.createInterpolatedDistribution
(double[] values, double[] cumulativeProbabilities) Create an empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createInterpolatedDistribution
(long[] values, double[] cumulativeProbabilities) Create an interpolated empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createInterpolatedDistribution
(Number[] values, double[] cumulativeProbabilities) Create an interpolated empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createInterpolatedDistribution
(List<? extends Number> values, List<Double> cumulativeProbabilities) Create an interpolated empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.createInterpolatedDistribution
(SortedMap<? extends Number, Double> cumulativeProbabilitiesMap) Create an interpolated empirical distribution based on a sorted map with sorted values mapping to cumulative probabilities.
-
Method Details
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(Number[] values, double[] cumulativeProbabilities) Create a discrete empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- Number[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is zero
-
createInterpolatedDistribution
public static InterpolatedEmpiricalDistribution createInterpolatedDistribution(Number[] values, double[] cumulativeProbabilities) Create an interpolated empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- Number[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is not zero, or there is only one value, so no interpolation can take place
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(double[] values, double[] cumulativeProbabilities) Create an empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- double[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is zero
-
createInterpolatedDistribution
public static InterpolatedEmpiricalDistribution createInterpolatedDistribution(double[] values, double[] cumulativeProbabilities) Create an empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- double[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is not zero, or there is only one value, so no interpolation can take place
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(long[] values, double[] cumulativeProbabilities) Create a discrete empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- long[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is zero
-
createInterpolatedDistribution
public static InterpolatedEmpiricalDistribution createInterpolatedDistribution(long[] values, double[] cumulativeProbabilities) Create an interpolated empirical distribution based on two arrays of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities. A copy of the original values is made to deal with mutability of the array.- Parameters:
values
- long[] the valuescumulativeProbabilities
- double[]; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution arrays
- Throws:
NullPointerException
- when cumulativeProbabilities array is null or values array is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is not zero, or there is only one value, so no interpolation can take place
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(List<? extends Number> values, List<Double> cumulativeProbabilities) Create a discrete empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.- Parameters:
values
- List<? extends Number>; the valuescumulativeProbabilities
- List<Double>; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution lists
- Throws:
NullPointerException
- when cumulativeProbabilities list is null, or when values list is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is zero
-
createInterpolatedDistribution
public static InterpolatedEmpiricalDistribution createInterpolatedDistribution(List<? extends Number> values, List<Double> cumulativeProbabilities) Create an interpolated empirical distribution based on two Lists of the same length, one with sorted values, and one with corresponding sorted cumulative probabilities.- Parameters:
values
- List<? extends Number>; the valuescumulativeProbabilities
- List<Double>; the cumulative probabilities for the corresponding values- Returns:
- the cumulative distribution object belonging to the given distribution lists
- Throws:
NullPointerException
- when cumulativeProbabilities list is null, or when values list is null, or when one of the values is nullIllegalArgumentException
- when cumulativeProbabilities array or values array are empty, or have unequal length, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is not zero, or there is only one value, so no interpolation can take place
-
createDiscreteDistribution
public static DiscreteEmpiricalDistribution createDiscreteDistribution(SortedMap<? extends Number, Double> cumulativeProbabilitiesMap) Create a discrete empirical distribution based on a sorted map with sorted values mapping to cumulative probabilities.- Parameters:
cumulativeProbabilitiesMap
- SortedMap<Number, Double>; the map with the entries- Returns:
- the cumulative distribution object belonging to the given distribution map
- Throws:
NullPointerException
- when cumulativeProbabilitiesMap is null, or when one of the values in the map is nullIllegalArgumentException
- when cumulativeProbabilitiesMap is empty, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is zero
-
createInterpolatedDistribution
public static InterpolatedEmpiricalDistribution createInterpolatedDistribution(SortedMap<? extends Number, Double> cumulativeProbabilitiesMap) Create an interpolated empirical distribution based on a sorted map with sorted values mapping to cumulative probabilities.- Parameters:
cumulativeProbabilitiesMap
- SortedMap<Number, Double>; the map with the entries- Returns:
- the cumulative distribution object belonging to the given distribution map
- Throws:
NullPointerException
- when cumulativeProbabilitiesMap is null, or when one of the values in the map is nullIllegalArgumentException
- when cumulativeProbabilitiesMap is empty, or when cumulativeProbabilities are not between 0 and 1, or when cumulativeProbabilities are not in ascending order, or when values are not in ascending order, or when the last cumulative probability is not 1.0, or when the first cumulative probability is not zero, or there is only one value, so no interpolation can take place
-