Class DistributionUtils


  • public class DistributionUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.Integer,​java.lang.Double> discretizeDistribution​(org.apache.commons.math3.distribution.RealDistribution dist, double binwidth)  
      static org.apache.commons.math3.analysis.UnivariateFunction getDensityFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
      Simply returns a wrapper function that returns the density.
      static int getIndex​(double value, double binwidth)
      The bin index starting with 0 for values between 0 inclusive and binwidth exclusive
      static double[] getRealPart​(org.apache.commons.math3.complex.Complex[] complexValues)
      Useful after operations in Fourier space.
      static double getReliableUpperBound​(org.apache.commons.math3.distribution.RealDistribution dist)  
      static double getValue​(int index, double binwidth)  
      static double[] getVectorLength​(org.apache.commons.math3.complex.Complex[] complexValues)  
      static org.apache.commons.math3.analysis.UnivariateFunction getWeightedFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
      Used for numerical integration to compute the mean.
      static org.apache.commons.math3.analysis.UnivariateFunction getWeightedSecondMomentFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
      Used for numerical integration to compute the variance.
      static double integrateReliably​(org.apache.commons.math3.analysis.UnivariateFunction f, double fromValue, double toValue)
      Integrates a function numerically with the SimpsonIntegrator.
      static double[] shuffle​(double[] values)  
      • Methods inherited from class java.lang.Object

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

      • DistributionUtils

        public DistributionUtils()
    • Method Detail

      • getWeightedFunction

        public static org.apache.commons.math3.analysis.UnivariateFunction getWeightedFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
        Used for numerical integration to compute the mean. given a distribution with a density, it returns a function of x * density(x)
        Parameters:
        dist -
        Returns:
      • getWeightedSecondMomentFunction

        public static org.apache.commons.math3.analysis.UnivariateFunction getWeightedSecondMomentFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
        Used for numerical integration to compute the variance. given a distribution with a density, it returns a function of x * density(x)
        Parameters:
        dist -
        Returns:
      • getDensityFunction

        public static org.apache.commons.math3.analysis.UnivariateFunction getDensityFunction​(org.apache.commons.math3.distribution.RealDistribution dist)
        Simply returns a wrapper function that returns the density.
        Parameters:
        dist - the distribution to extract the density from.
        Returns:
        UnivariateFunction
      • getRealPart

        public static double[] getRealPart​(org.apache.commons.math3.complex.Complex[] complexValues)
        Useful after operations in Fourier space.
        Parameters:
        complexValues -
        Returns:
        extracts the real part of the complex numbers
      • getVectorLength

        public static double[] getVectorLength​(org.apache.commons.math3.complex.Complex[] complexValues)
      • shuffle

        public static double[] shuffle​(double[] values)
      • discretizeDistribution

        public static java.util.Map<java.lang.Integer,​java.lang.Double> discretizeDistribution​(org.apache.commons.math3.distribution.RealDistribution dist,
                                                                                                     double binwidth)
      • getIndex

        public static int getIndex​(double value,
                                   double binwidth)
        The bin index starting with 0 for values between 0 inclusive and binwidth exclusive
        Parameters:
        value -
        binwidth -
        Returns:
      • getValue

        public static double getValue​(int index,
                                      double binwidth)
      • integrateReliably

        public static double integrateReliably​(org.apache.commons.math3.analysis.UnivariateFunction f,
                                               double fromValue,
                                               double toValue)
        Integrates a function numerically with the SimpsonIntegrator. Does so 10 times with less and less accuracy.
        Parameters:
        f - the function to be integrated
        fromValue - the lower boundary of the integral
        toValue - the upper boundary of the integral
        Returns:
        double the value of the integral
        Throws:
        java.lang.IllegalArgumentException - if integration fails 10 times (with less and less accuracy)
      • getReliableUpperBound

        public static double getReliableUpperBound​(org.apache.commons.math3.distribution.RealDistribution dist)