Class ProbabilityDistributions

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Random randomGenerator
      Random number generator
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double cdfChiSquared​(double x, double k)
      Cumulative distribution function - Chi-Squared distribution
      static double cdfNormal​(double x, double mean, double stddev)
      CDF - Cumulative Distribution Function - Normal distribution N(mean, stddev).
      static double cdfStudentT​(double x, double v)
      Cumulative distribution function - Student's t-distribution
      static double cdfUniformContinuous​(double x, double a, double b)
      CDF - Cumulative Distribution Function - Uniform Continuous distribution over interval [a, b).
      static double pdfChiSquared​(double x, double k)
      Probability distribution function - Chi-Squared distribution
      static double pdfNormal​(double x, double mean, double stddev)
      PDF - Probability Distribution Function - Normal distribution N(mean, stddev).
      static double pdfStudentT​(double x, double v)
      Probability distribution function - Student's t-distribution
      static double pdfUniformContinuous​(double x, double a, double b)
      PDF - Probability Distribution Function - Uniform Continuous distribution over interval [a, b).
      static double qntChiSquared​(double p, double k)
      Quantile function (Inverse cumulative distribution function) - Chi-Squared distribution
      static double qntNormal​(double q, double mean, double stddev)
      QNT - Quantile Function - Normal distribution N(mean, stddev).
      static double qntStudentT​(double p, double v)
      Quantile function (Inverse cumulative distribution function) - Student's t-distribution
      static double qntUniformContinuous​(double q, double a, double b)
      QNT - Quantile Function - Uniform Continuous distribution over interval [a, b).
      static double randomUniformContinuous()
      Random number from Uniform Continuous distribution over interval [0, 1).
      static double rndChiSquared​(double k)
      Pseudo-random number from Chi-Squared distribution
      static int rndIndex​(int n)
      Random index from 0 to n-1,
      static int rndIndex​(int n, Random rnd)
      Random index from 0 to n-1,
      static int rndInteger()
      Random integer.
      static double rndInteger​(int a, int b)
      Random number from Uniform Discrete distribution.
      static double rndInteger​(int a, int b, Random rnd)
      Random number from Uniform Discrete distribution.
      static int rndInteger​(Random rnd)
      Random integer.
      static double rndNormal​(double mean, double stddev)
      Random number from normal distribution N(mean, stddev).
      static double rndNormal​(double mean, double stddev, Random rnd)
      Random number from normal distribution N(mean, stddev).
      static double rndStudentT​(double v)
      Pseudo-random number from Student's t-distribution
      static double rndUniformContinuous​(double a, double b)
      Random number from dUniform Continuous distribution over interval [a, b).
      static double rndUniformContinuous​(double a, double b, Random rnd)
      Random number from Uniform Continuous distribution over interval [a, b).
      static double rndUniformContinuous​(Random rnd)
      Random number from Uniform Continuous distribution over interval [0, 1).
    • Field Detail

      • randomGenerator

        public static Random randomGenerator
        Random number generator
    • Constructor Detail

      • ProbabilityDistributions

        public ProbabilityDistributions()
    • Method Detail

      • rndUniformContinuous

        public static double rndUniformContinuous​(double a,
                                                  double b,
                                                  Random rnd)
        Random number from Uniform Continuous distribution over interval [a, b).
        Parameters:
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        rnd - Random number generator.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise returns random number.
      • rndUniformContinuous

        public static double rndUniformContinuous​(double a,
                                                  double b)
        Random number from dUniform Continuous distribution over interval [a, b).
        Parameters:
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise returns random number.
      • rndUniformContinuous

        public static double rndUniformContinuous​(Random rnd)
        Random number from Uniform Continuous distribution over interval [0, 1).
        Parameters:
        rnd - Random number generator.
        Returns:
        Random number.
      • randomUniformContinuous

        public static double randomUniformContinuous()
        Random number from Uniform Continuous distribution over interval [0, 1).
        Returns:
        Random number.
      • pdfUniformContinuous

        public static double pdfUniformContinuous​(double x,
                                                  double a,
                                                  double b)
        PDF - Probability Distribution Function - Uniform Continuous distribution over interval [a, b).
        Parameters:
        x - Point to evaluate pdf function.
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise function value.
      • cdfUniformContinuous

        public static double cdfUniformContinuous​(double x,
                                                  double a,
                                                  double b)
        CDF - Cumulative Distribution Function - Uniform Continuous distribution over interval [a, b).
        Parameters:
        x - Point to evaluate cdf function.
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise function value.
      • qntUniformContinuous

        public static double qntUniformContinuous​(double q,
                                                  double a,
                                                  double b)
        QNT - Quantile Function - Uniform Continuous distribution over interval [a, b). (Inverse of Cumulative Distribution Function).
        Parameters:
        q - Quantile.
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        Returns:
        Double.NaN if a or b is null, or b is lower than a or q is lower than 0 or q is greater than 1 - otherwise function value.
      • rndInteger

        public static double rndInteger​(int a,
                                        int b,
                                        Random rnd)
        Random number from Uniform Discrete distribution. over set interval (a, a+1, ..., b-1, b).
        Parameters:
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        rnd - Random number generator.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise returns random number.
      • rndInteger

        public static double rndInteger​(int a,
                                        int b)
        Random number from Uniform Discrete distribution. over set interval (a, a+1, ..., b-1, b).
        Parameters:
        a - Interval limit - left / lower.
        b - Interval limit - right / upper.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise returns random number.
      • rndInteger

        public static int rndInteger​(Random rnd)
        Random integer.
        Parameters:
        rnd - Random number generator.
        Returns:
        Returns random number.
      • rndIndex

        public static int rndIndex​(int n,
                                   Random rnd)
        Random index from 0 to n-1,
        Parameters:
        n - Bound.
        rnd - Random number generator.
        Returns:
        if n < 0 returns -1, otherwise random index.
      • rndIndex

        public static int rndIndex​(int n)
        Random index from 0 to n-1,
        Parameters:
        n - Bound.
        Returns:
        if n < 0 returns -1, otherwise random index.
      • rndInteger

        public static int rndInteger()
        Random integer.
        Returns:
        Double.NaN if a or b is null, or b is lower than a - otherwise returns random number.
      • rndNormal

        public static double rndNormal​(double mean,
                                       double stddev,
                                       Random rnd)
        Random number from normal distribution N(mean, stddev).
        Parameters:
        mean - Mean value.
        stddev - Standard deviation.
        rnd - Random number generator.
        Returns:
        Double.NaN if mean or stddev or rnd is null or stddev is lower than 0 - otherwise random number.
      • rndNormal

        public static double rndNormal​(double mean,
                                       double stddev)
        Random number from normal distribution N(mean, stddev).
        Parameters:
        mean - Mean value.
        stddev - Standard deviation.
        Returns:
        Double.NaN if mean or stddev is null or stddev is lower than 0 - otherwise random number.
      • pdfNormal

        public static double pdfNormal​(double x,
                                       double mean,
                                       double stddev)
        PDF - Probability Distribution Function - Normal distribution N(mean, stddev).
        Parameters:
        x - Point to evaluate pdf function.
        mean - Mean value.
        stddev - Standard deviation.
        Returns:
        Double.NaN if mean or stddev is null or stddev is lower than 0 - otherwise function value.
      • cdfNormal

        public static double cdfNormal​(double x,
                                       double mean,
                                       double stddev)
        CDF - Cumulative Distribution Function - Normal distribution N(mean, stddev).
        Parameters:
        x - Point to evaluate pdf function.
        mean - Mean value.
        stddev - Standard deviation.
        Returns:
        Double.NaN if mean or stddev is null or stddev is lower than 0 - otherwise function value.
      • qntNormal

        public static double qntNormal​(double q,
                                       double mean,
                                       double stddev)
        QNT - Quantile Function - Normal distribution N(mean, stddev). (Inverse of Cumulative Distribution Function).
        Parameters:
        q - Quantile.
        mean - Mean value.
        stddev - Standard deviation.
        Returns:
        Double.NaN if mean or stddev is null or stddev is lower than 0 or q is lower than 0 or q is greater than 1 - otherwise function value.
      • pdfStudentT

        public static double pdfStudentT​(double x,
                                         double v)
        Probability distribution function - Student's t-distribution
        Parameters:
        x - Given point.
        v - Number of degrees of freedom.
        Returns:
        Returns the PDF of Student's t-distribution.
      • cdfStudentT

        public static double cdfStudentT​(double x,
                                         double v)
        Cumulative distribution function - Student's t-distribution
        Parameters:
        x - Given point.
        v - Number of degrees of freedom.
        Returns:
        Returns the CDF of Student's t-distribution.
      • qntStudentT

        public static double qntStudentT​(double p,
                                         double v)
        Quantile function (Inverse cumulative distribution function) - Student's t-distribution
        Parameters:
        p - Probability
        v - Number of degrees of freedom.
        Returns:
        Returns the quantile of Student's t-distribution
      • rndStudentT

        public static double rndStudentT​(double v)
        Pseudo-random number from Student's t-distribution
        Parameters:
        v - Number of degrees of freedom.
        Returns:
        returns Pseudo-random number from Student's t-distribution
      • pdfChiSquared

        public static double pdfChiSquared​(double x,
                                           double k)
        Probability distribution function - Chi-Squared distribution
        Parameters:
        x - Given point.
        k - Number of degrees of freedom.
        Returns:
        Returns the PDF of Chi-Squared t-distribution.
      • cdfChiSquared

        public static double cdfChiSquared​(double x,
                                           double k)
        Cumulative distribution function - Chi-Squared distribution
        Parameters:
        x - Given point.
        k - Number of degrees of freedom.
        Returns:
        Returns the CDF of Chi-Squared distribution.
      • qntChiSquared

        public static double qntChiSquared​(double p,
                                           double k)
        Quantile function (Inverse cumulative distribution function) - Chi-Squared distribution
        Parameters:
        p - Probability
        k - Number of degrees of freedom.
        Returns:
        Returns the quantile of Chi-Squared distribution
      • rndChiSquared

        public static double rndChiSquared​(double k)
        Pseudo-random number from Chi-Squared distribution
        Parameters:
        k - Number of degrees of freedom.
        Returns:
        returns Pseudo-random number from Chi-Squared distribution