Class ProbUtils

java.lang.Object
edu.cmu.tetrad.util.ProbUtils

public class ProbUtils extends Object

Implements a number of important functions from probability and statistics.> 0

We don't know who wrote this class; we didn't. All we added was the documentation. -Joe Ramsey, jdramsey@andrew.cmu.edu> 0

Author:
Unknown, but thanks
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bernoulliRand(double p)
     
    static double
    betaCdf(double x, double pin, double qin)
    Incomplete Beta function.
    static double
    betaPdf(double x, double a, double b)
     
    static double
    betaQuantile(double alpha, double p, double q)
     
    static double
    betaRand(double a, double b)
    Beta distribution random generator.
    static double
    binomialCdf(int k, int n, double p)
    Binomial cumulative distribution function.
    static double
    binomialPmf(int k, int n, double p)
     
    static int
    binomialQuantile(double x, int n, double p)
     
    static int
    binomialRand(int n, double pp)
    Binomial random generator from Numerical Recipes
    static double
    biNormalCdf(double ah, double ak, double r)
    Bivariate normal CDF.
    static double
    cauchyCdf(double x)
    Cauchy CDF
    static double
    cauchyPdf(double x)
     
    static double
    cauchyQuantile(double x)
     
    static double
    Cauchy random generator.
    static double
    chisqCdf(double x, double df)
     
    static double
    chisqPdf(double x, double v)
     
    static double
    chisqQuantile(double p, double v)
     
    static double
    chisqRand(double df)
    Chi square random generator.
    static double
    fCdf(double x, double df1, double df2)
    F CDF.
    static double
    fPdf(double x, double a, double b)
     
    static double
    fQuantile(double p, double df1, double df2)
     
    static double
    fRand(double ndf, double ddf)
    F distribution random generator.
    static double
    gammaCdf(double a, double x)
    compute complementary gamma cdf by its continued fraction expansion
    static double
    gammaPdf(double x, double a)
     
    static double
    gammaQuantile(double a, double p)
     
    static double
    gammaRand(double a)
    Gamma random generator.
    static double
    lngamma(double xx)
    This is a more literal (that is, exact) copy of the log gamma method from Numerical Recipes than the following one.
    static double
    logbeta(double p, double q)
    Calculates the log beta function of p and q.
    static double
    multinormalProb(double[] a, double[] b, double[][] cov)
    Compute the probability over a rectangular region with correlation matrix c.
    static double
    normalCdf(double y)
    Normal cumulative distribution function (the value which results by integrating the normal distribution function from negative infinity up to y).
    static double
    normalPdf(double x)
     
    static double
    normalQuantile(double p)
     
    static double
    Normal random generator
    static double
    poissonCdf(int k, double y)
     
    static double
    poissonPmf(int k, double lambda)
     
    static int
    poissonQuantile(double x, double l)
     
    static int
    poissonRand(double xm)
    Poisson random generator from Numerical Recipes
    static double
    tCdf(double x, double df)
    CACM Algorithm 395, by G.
    static double
    tPdf(double x, double a)
     
    static double
    tQuantile(double pp, double n)
    CACM Algorithm 396, by G.
    static double
    tRand(double df)
    T distribution random generator.
    static double
     
    static void
    uniformSeeds(long a, long b)
     

    Methods inherited from class java.lang.Object

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

    • ProbUtils

      public ProbUtils()
  • Method Details

    • normalCdf

      public static double normalCdf(double y)
      Normal cumulative distribution function (the value which results by integrating the normal distribution function from negative infinity up to y).
      Parameters:
      y - the upper limit of integration.
      Returns:
      the area accumulated in the integration.
    • lngamma

      public static double lngamma(double xx)
      This is a more literal (that is, exact) copy of the log gamma method from Numerical Recipes than the following one. It was created by cutting and pasting from the PDF version of the book and then converting C syntax to Java. The static double array above goes with this. Converted to Java by Frank Wimberly
      Returns:
      the value ln[?(xx)] for xx > 0
    • logbeta

      public static double logbeta(double p, double q)
      Calculates the log beta function of p and q.
    • betaCdf

      public static double betaCdf(double x, double pin, double qin)
      Incomplete Beta function. Translated from FORTRAN july 1977 edition. w. fullerton, c3, los alamos scientific lab. based on bosten and battiste, remark on algorithm 179, comm. acm, v 17, p 153, (1974).
      Parameters:
      x - upper limit of integration. x must be in (0,1) inclusive.
      pin - first beta distribution parameter. p must be gt 0.0.
      qin - second beta distribution parameter. q must be gt 0.0.
      Returns:
      result.
    • binomialCdf

      public static double binomialCdf(int k, int n, double p)
      Binomial cumulative distribution function.
    • cauchyCdf

      public static double cauchyCdf(double x)
      Cauchy CDF
    • fCdf

      public static double fCdf(double x, double df1, double df2)
      F CDF.
    • gammaCdf

      public static double gammaCdf(double a, double x)
      compute complementary gamma cdf by its continued fraction expansion
    • chisqCdf

      public static double chisqCdf(double x, double df)
    • poissonCdf

      public static double poissonCdf(int k, double y)
    • tCdf

      public static double tCdf(double x, double df)
      CACM Algorithm 395, by G. W. Hill
    • betaQuantile

      public static double betaQuantile(double alpha, double p, double q)
    • binomialQuantile

      public static int binomialQuantile(double x, int n, double p)
    • cauchyQuantile

      public static double cauchyQuantile(double x)
    • chisqQuantile

      public static double chisqQuantile(double p, double v)
    • fQuantile

      public static double fQuantile(double p, double df1, double df2)
    • gammaQuantile

      public static double gammaQuantile(double a, double p)
    • normalQuantile

      public static double normalQuantile(double p)
    • poissonQuantile

      public static int poissonQuantile(double x, double l)
    • tQuantile

      public static double tQuantile(double pp, double n)
      CACM Algorithm 396, by G. W. Hill
    • betaPdf

      public static double betaPdf(double x, double a, double b)
    • binomialPmf

      public static double binomialPmf(int k, int n, double p)
    • cauchyPdf

      public static double cauchyPdf(double x)
    • chisqPdf

      public static double chisqPdf(double x, double v)
    • fPdf

      public static double fPdf(double x, double a, double b)
    • gammaPdf

      public static double gammaPdf(double x, double a)
    • normalPdf

      public static double normalPdf(double x)
    • poissonPmf

      public static double poissonPmf(int k, double lambda)
    • tPdf

      public static double tPdf(double x, double a)
    • uniformSeeds

      public static void uniformSeeds(long a, long b)
    • uniformRand

      public static double uniformRand()
    • bernoulliRand

      public static int bernoulliRand(double p)
    • poissonRand

      public static int poissonRand(double xm)
      Poisson random generator from Numerical Recipes
    • binomialRand

      public static int binomialRand(int n, double pp)
      Binomial random generator from Numerical Recipes
    • normalRand

      public static double normalRand()
      Normal random generator
    • cauchyRand

      public static double cauchyRand()
      Cauchy random generator.
    • gammaRand

      public static double gammaRand(double a)
      Gamma random generator.
    • chisqRand

      public static double chisqRand(double df)
      Chi square random generator.
    • tRand

      public static double tRand(double df)
      T distribution random generator.
    • betaRand

      public static double betaRand(double a, double b)
      Beta distribution random generator.
    • fRand

      public static double fRand(double ndf, double ddf)
      F distribution random generator.
    • biNormalCdf

      public static double biNormalCdf(double ah, double ak, double r)
      Bivariate normal CDF. Adapted from statlib, file general/gaut.c, by Ajay Shah. Adaptation for Java found here --November 1st 2003, Ricardo Silva
      Parameters:
      ah - upper bound 1
      ak - upper bound 1
      r - correlatiohn
      Returns:
      Prob(x1 & le ; ah, x2 & le ; ak)
    • multinormalProb

      public static double multinormalProb(double[] a, double[] b, double[][] cov)
      Compute the probability over a rectangular region with correlation matrix c. Algorithm extracted from Alan Genz: Numerical Computation of Multivariate Normal Probabilities; revised version published in J. Comp. Graph Stat. 1 (1992), pp. 141-149. http://www.math.wsu.edu/faculty/genz/homepage Warning: this method has the side effect of changing the order of the elements in the arrays given as input. --November 3st 2003, Ricardo Silva
      Parameters:
      a - lower bounds (use Double.NEGATIVE_INFINITY if necessary)
      b - upper bounds (use Double.POSITIVE_INFINITY if necessary)