Class CumulativeProbabilities

java.lang.Object
nl.tudelft.simulation.jstats.distributions.empirical.CumulativeProbabilities

public final class CumulativeProbabilities extends Object
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 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 values
      cumulativeProbabilities - 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 null
      IllegalArgumentException - 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 null
      IllegalArgumentException - 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 null
      IllegalArgumentException - 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