edu.cmu.cs.sb.core
Class StatUtil

java.lang.Object
  extended by edu.cmu.cs.sb.core.StatUtil

public class StatUtil
extends java.lang.Object

The class implements static methods to compute values related to the binomial, hypergeometric, and normal distribution


Field Summary
static java.util.Hashtable htbinom
          this hashtable caches previously computed binomial coefficient values so they do not need to be recomputed
static double TWOPISQRT
          Sqrt of 2 times PI
 
Constructor Summary
StatUtil()
           
 
Method Summary
static double binomialcumulative(double x, double dN, double dp)
          Computes the probability of seeing x or fewer successes in dN trials where the probability of a success is dp.
static double binomialtail(int x, int N, double dp)
          Computes the probability of seeing more than x successes in N trials where the probability of a success is dp.
static double hypergeometric(int nx, int nA, int nB, int nm)
          Returns the probability of seeing x of type A, when there nA objects of type A nB objects of type B, and nm objects total drawn
static double hypergeometriccumulativex(int nx, int nA, int nB, int nm)
          Returns the probability of seeing x or fewer objects of type A, when there are nA objects of type A nB objects of type B, and nm objects total drawn
static double hypergeometrictail(int nx, int nA, int nB, int nm)
          Returns the probability of seeing more than x objects of type A, when there are nA objects of type A nB objects of type B, and nm objects total drawn This can be used to compute a more accurate p-values than a 1-cumulative probability calculation
static double logbinomcoeff(int ni, int N)
          Returns the log of the binomial coefficient N choose ni
static double normaldensity(double x, double dmu, double dsigma)
          computes the value of f(x) where f is a density for a normal distribution with mean dmu and standard deviation dsigma.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

htbinom

public static java.util.Hashtable htbinom
this hashtable caches previously computed binomial coefficient values so they do not need to be recomputed


TWOPISQRT

public static double TWOPISQRT
Sqrt of 2 times PI

Constructor Detail

StatUtil

public StatUtil()
Method Detail

logbinomcoeff

public static double logbinomcoeff(int ni,
                                   int N)
Returns the log of the binomial coefficient N choose ni


hypergeometric

public static double hypergeometric(int nx,
                                    int nA,
                                    int nB,
                                    int nm)
Returns the probability of seeing x of type A, when there nA objects of type A nB objects of type B, and nm objects total drawn


hypergeometrictail

public static double hypergeometrictail(int nx,
                                        int nA,
                                        int nB,
                                        int nm)
Returns the probability of seeing more than x objects of type A, when there are nA objects of type A nB objects of type B, and nm objects total drawn This can be used to compute a more accurate p-values than a 1-cumulative probability calculation


hypergeometriccumulativex

public static double hypergeometriccumulativex(int nx,
                                               int nA,
                                               int nB,
                                               int nm)
Returns the probability of seeing x or fewer objects of type A, when there are nA objects of type A nB objects of type B, and nm objects total drawn


binomialcumulative

public static double binomialcumulative(double x,
                                        double dN,
                                        double dp)
Computes the probability of seeing x or fewer successes in dN trials where the probability of a success is dp.


binomialtail

public static double binomialtail(int x,
                                  int N,
                                  double dp)
Computes the probability of seeing more than x successes in N trials where the probability of a success is dp.


normaldensity

public static double normaldensity(double x,
                                   double dmu,
                                   double dsigma)
computes the value of f(x) where f is a density for a normal distribution with mean dmu and standard deviation dsigma.