Class Probability

java.lang.Object
utils.Probability

public class Probability extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    cdfToPMF(double[] CDF)
    Converts a CDF P(X ≤ t) to the respective distribution's PMF P(X = t).
    static double[]
    discreteUniform(int lower, int upper, boolean cumulative)
     
    static double
    equalTo(double[] pmf, int lowerbound, int x)
     
    static double
    equalToFromCDF(double[] CDF, int lowerbound, int x)
     
    static double
    equalToFromSurvival(double[] survival, int lowerbound, int x)
     
    static double
    greaterOrEqual(double[] survival, int lowerbound, int x)
     
    static double
    greaterOrEqualFromCDF(double[] CDF, int lowerbound, int x)
     
    static double
    lesserOrEqual(double[] CDF, int lowerbound, int x)
     
    static double
    lesserOrEqualFromSurvival(double[] survival, int lowerbound, int x)
     
    static double[]
    minOrMaxDistribution(double[][] CDFs, int[] lowerbounds, int lower, int upper, boolean cumulative)
    Computes the distribution resulting from taking the maximum or minimum of multiple random variables.
    static double[]
    survivalToPMF(double[] survival)
    Converts a Survival function P(X ≥ t) to the respective distribution's PMF P(X = t).
    static double[]
    toCDF(double[] survival)
    Converts a Survival function P(X ≥ t) to the respective distribution's CDF P(X ≤ t).
    static double[]
    toPMF(double[] distribution, boolean cumulative)
    Converts a CDF/Survival Function to PMF based on the cumulative flag.
    static double[]
    toSurvival(double[] cdf)
    Converts a CDF P(X ≤ t) to the respective distribution's Survival Function P(X ≥ t).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Probability

      public Probability()
  • Method Details

    • greaterOrEqual

      public static double greaterOrEqual(double[] survival, int lowerbound, int x)
    • greaterOrEqualFromCDF

      public static double greaterOrEqualFromCDF(double[] CDF, int lowerbound, int x)
    • lesserOrEqual

      public static double lesserOrEqual(double[] CDF, int lowerbound, int x)
    • lesserOrEqualFromSurvival

      public static double lesserOrEqualFromSurvival(double[] survival, int lowerbound, int x)
    • equalTo

      public static double equalTo(double[] pmf, int lowerbound, int x)
    • equalToFromCDF

      public static double equalToFromCDF(double[] CDF, int lowerbound, int x)
    • equalToFromSurvival

      public static double equalToFromSurvival(double[] survival, int lowerbound, int x)
    • toSurvival

      public static double[] toSurvival(double[] cdf)
      Converts a CDF P(X ≤ t) to the respective distribution's Survival Function P(X ≥ t).

      Assumes that the given array spans the entire domain of the distribution.

      Parameters:
      cdf - the Cumulative Distribution Function (CDF)
      Returns:
      the Survival Function
    • toCDF

      public static double[] toCDF(double[] survival)
      Converts a Survival function P(X ≥ t) to the respective distribution's CDF P(X ≤ t).

      Assumes that the given array spans the entire domain of the distribution.

      Parameters:
      survival - the Survival Function
      Returns:
      the Cumulative Distribution Function (CDF)
    • cdfToPMF

      public static double[] cdfToPMF(double[] CDF)
      Converts a CDF P(X ≤ t) to the respective distribution's PMF P(X = t).

      Assumes that the given array spans the entire domain of the distribution.

      Parameters:
      CDF - the Cumulative Distribution Function (CDF)
      Returns:
      the Probability Mass Function (PMF)
    • survivalToPMF

      public static double[] survivalToPMF(double[] survival)
      Converts a Survival function P(X ≥ t) to the respective distribution's PMF P(X = t).

      Assumes that the given array spans the entire domain of the distribution.

      Parameters:
      survival - the Survival Function
      Returns:
      the Probability Mass Function (PMF)
    • toPMF

      public static double[] toPMF(double[] distribution, boolean cumulative)
      Converts a CDF/Survival Function to PMF based on the cumulative flag.
      Parameters:
      distribution - The distribution (CDF if cumulative = true, Survival Function if cumulative = false)
      cumulative - Whether the input is cumulative (true: CDF) or subtractive (false: Survival Function).
      Returns:
      the Probability Mass Function (PMF)
    • discreteUniform

      public static double[] discreteUniform(int lower, int upper, boolean cumulative)
      Parameters:
      lower - inclusive lower bound of the interval
      upper - inclusive upper bound of the interval
      cumulative - whether to return the CDF of the interval (cumulative = true) or the Survival Function of the interval (cumulative = false).
      Returns:
      the discrete CDF or Survival Function of a uniform distribution spanning the given lower and upper bounds
    • minOrMaxDistribution

      public static double[] minOrMaxDistribution(double[][] CDFs, int[] lowerbounds, int lower, int upper, boolean cumulative)
      Computes the distribution resulting from taking the maximum or minimum of multiple random variables.
      Parameters:
      CDFs - The CDFs or Survival Functions of the distributions to be combined
      lowerbounds - lower bounds of each of the distributions provided. The upper bound is encoded in the lengths of the arrays.
      lower - lower bound of the resulting function (maximum lowerbound of the lowerbounds of the CDFs)
      upper - upper bound of the resulting function (maximum upperbound of the upperbounds of the CDFs)
      cumulative - true if the given functions are cumulative (CDF) and false if the given functions are subtractive (Survival Function).
      Returns:
      The combined CDF or Survival Function of the given distributions, representing the distribution of the maximum (cumulative = true) or minimum (cumulative = false) of the random variables given by CDFs and lowerbounds