sir.util
Class Distributions

java.lang.Object
  extended byorg.omegahat.Probability.Distributions.DistributionFunctions
      extended bysir.util.Distributions

public class Distributions
extends org.omegahat.Probability.Distributions.DistributionFunctions

Class extending the set of distributions. In the Hydra package all distributions are in one file not OO-split. Bad! Should use the CERN package for this!

Current extension consists of the gamma distribution with both scale and shape parameter. And incomplete gamma function.

Version:
20 August 2001. Last modified 7 January 2003
Author:
Michael Höhle <hoehle@dina.kvl.dk>
See Also:
PRNGDistributionFunctions

Field Summary
 
Fields inherited from class org.omegahat.Probability.Distributions.DistributionFunctions
geometricRand_beta, geometricRand_last_p
 
Constructor Summary
Distributions(org.omegahat.Simulation.RandomGenerators.PRNG prng_in)
          Constructor
 
Method Summary
 double gammaCDF(double q, double alpha, double beta)
          CDF i.e. probability function of a Ga(alpha,beta) distribution
 double gammaPDF(double x, double alpha, double beta)
          Find pdf value at X=x, when X~\Gamma(alpha,beta), i.e.
 double gammaQuantile(double p, double alpha, double beta)
          Quantile of a Ga(p,alpha,beta) distribution (i.e. inverse of CDF)
 double gammaRand(double alpha, double beta)
          Sample X ~ Gamma(alpha,beta) , s.t.
 double gammaSurv(double x, double alpha, double beta)
          Survival function S(t) of the gamma distribution with parameters a and b
 double gammaTruncRand(double alpha, double beta, double T)
          Sample a random number of a left truncated Ga(alpha,beta) distribution using inversion sampling.
 org.omegahat.Simulation.RandomGenerators.PRNG getPRNG()
          Straight accessor function
 double loggammaPDF(double x, double alpha, double beta)
          My own distribution function on log scale to make sure I got things right.
 void setPRNG(org.omegahat.Simulation.RandomGenerators.PRNG prng_in)
           
 double uniformRand()
          Overwrite the uniformRand method so we use the better PRNG!
 
Methods inherited from class org.omegahat.Probability.Distributions.DistributionFunctions
bernoulliRand, betaCDF, betaPDF, betaQuantile, betaRand, binomialCDF, binomialPMF, binomialQuantile, binomialRand, cauchyCDF, cauchyPDF, cauchyQuantile, cauchyRand, chisqCDF, chisqPDF, chisqQuantile, chisqRand, dirichletPDF, dirichletRand, exponentialRand, exponentialRand, fCDF, fPDF, fQuantile, fRand, gammaCDF, gammaPDF, gammaQuantile, gammaRand, geometricCDF, geometricPMF, geometricQuantile, geometricRand, hypergeometricCDF, hypergeometricPMF, lngamma, logbeta, macheps, normalCDF, normalPDF, normalQuantile, normalRand, poissonCDF, poissonPMF, poissonQuantile, poissonRand, tCDF, tPDF, tQuantile, tRand, uniformSeeds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distributions

public Distributions(org.omegahat.Simulation.RandomGenerators.PRNG prng_in)
Constructor

Method Detail

getPRNG

public org.omegahat.Simulation.RandomGenerators.PRNG getPRNG()
Straight accessor function


setPRNG

public void setPRNG(org.omegahat.Simulation.RandomGenerators.PRNG prng_in)

uniformRand

public double uniformRand()
Overwrite the uniformRand method so we use the better PRNG!


gammaRand

public double gammaRand(double alpha,
                        double beta)
Sample X ~ Gamma(alpha,beta) , s.t. E[X] = alpha/beta and V[X] = alpha/beta^2.


gammaPDF

public double gammaPDF(double x,
                       double alpha,
                       double beta)
Find pdf value at X=x, when X~\Gamma(alpha,beta), i.e. E[X] = alpha/beta and V[X] = alpha/beta^2.


loggammaPDF

public double loggammaPDF(double x,
                          double alpha,
                          double beta)
My own distribution function on log scale to make sure I got things right. Problem: This function is called heavily and should really be optimized. I don't get why StrictMath.log is called, but we have a bit too many Log's and stuff? So now it's renamed to loggammaPDF2 and we have a native version. In IBM JVM it appears to run better so no need for native calls there...


gammaSurv

public double gammaSurv(double x,
                        double alpha,
                        double beta)
Survival function S(t) of the gamma distribution with parameters a and b

Parameters:
x - Time value
alpha - Shape parameter of gamma distribution (aka. gamma)
beta - 1/Scale parameter of gamma distribution.

gammaQuantile

public double gammaQuantile(double p,
                            double alpha,
                            double beta)
Quantile of a Ga(p,alpha,beta) distribution (i.e. inverse of CDF)

Parameters:
p - The prob to compute quantile for
alpha - alpha param
beta - beta param
Returns:
qgamma(p,alpha,beta) (R syntax)

gammaCDF

public double gammaCDF(double q,
                       double alpha,
                       double beta)
CDF i.e. probability function of a Ga(alpha,beta) distribution

Parameters:
alpha - alpha paramter of Ga(alpha,beta) distrib.
beta - bets paramter of Ga(alpha,beta) distrib.
Returns:
pgamma(q,alpha,beta)

gammaTruncRand

public double gammaTruncRand(double alpha,
                             double beta,
                             double T)
Sample a random number of a left truncated Ga(alpha,beta) distribution using inversion sampling.

Parameters:
alpha - alpha paramter of Ga(alpha,beta) distrib.
beta - bets paramter of Ga(alpha,beta) distrib.
T - point of (left) truncation