blog.distrib
Class Gamma

java.lang.Object
  extended by blog.AbstractCondProbDistrib
      extended by blog.distrib.Gamma
All Implemented Interfaces:
CondProbDistrib

public class Gamma
extends AbstractCondProbDistrib

A Gamma distribution with shape parameter k and scale parameter 1/lambda. Defined as f(x) = (lambda*e^(-lambda*x)*(lambda*x)^(k - 1)) / Gamma(k) where Gamma(k) = integral from 0 to infinity of t^(k-1) * e^(-t) dt


Constructor Summary
Gamma(double k, double lambda)
          Creates a new Gamma distribution with parameters k and lambda.
Gamma(java.util.List params)
          Creates a new Gamma distribution with parameters k and lambda.
 
Method Summary
static double gamma(double x)
           
 double getLogProb(java.util.List args, java.lang.Object value)
          Returns the log of the probability of x under this distribution.
 double getProb(java.util.List args, java.lang.Object value)
          Returns the probability of x under this distribution
static double lgamma(double x)
           
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Returns a double sampled according to this distribution.
 
Methods inherited from class blog.AbstractCondProbDistrib
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gamma

public Gamma(java.util.List params)
Creates a new Gamma distribution with parameters k and lambda.


Gamma

public Gamma(double k,
             double lambda)
Creates a new Gamma distribution with parameters k and lambda.

Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Returns the probability of x under this distribution


getLogProb

public double getLogProb(java.util.List args,
                         java.lang.Object value)
Returns the log of the probability of x under this distribution.

Specified by:
getLogProb in interface CondProbDistrib
Overrides:
getLogProb in class AbstractCondProbDistrib

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Returns a double sampled according to this distribution. Uniformly fast for all k > 0. (Reference: Non-Uniform Random Variate Generation, Devroye http://cgm.cs.mcgill.ca/~luc/rnbookindex.html) Uses Cheng's rejection algorithm (GB) for k>=1, rejection from Weibull distribution for 0 < k < 1.


gamma

public static double gamma(double x)

lgamma

public static double lgamma(double x)