Class Sample


public class Sample
extends Object

A utility class containing methods for sampling from various probability distributions. The implementations used here are borrowed directly from Tom Minka's Lightspeed library for Matlab.

This class records counts of all floating point operations using Flops.count(long).

Field Summary
static double DBL_EPSILON
          Analogous to eps in Matlab.
Constructor Summary
Method Summary
static double beta(double a, double b, Random r)
          Returns a sample from Beta(a, b).
static int binomial(int n, double p, Random r)
          Returns a sample from Binomial(n, p).
static double gamma(double a, Random r)
          Samples from the Gamma(a) distribution.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final double DBL_EPSILON
Analogous to eps in Matlab.

See Also:
Constant Field Values
Constructor Detail


public Sample()
Method Detail


public static double gamma(double a,
                           Random r)
Samples from the Gamma(a) distribution. This implementation is from BUGS.


public static double beta(double a,
                          double b,
                          Random r)
Returns a sample from Beta(a, b).


public static int binomial(int n,
                           double p,
                           Random r)
Returns a sample from Binomial(n, p).