|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Random
vec_math.PoissonRandom
public class PoissonRandom
Extends the random function to include Poisson-distributed random variable Uses algorithm of Ahrean & Dieter, 'Computer Methods for Sampling from Gamma, Beta, Poisson and Binominal Distributions', Computing 12, p223ff 1974. Currently, only the gamma method is implemented, which have a cost of order of ln(μ).
For other distributions, either use the inverse transform sampling theorem, which says that an cdf (cumulative distribution function cdf(x) = ∫_-&inf;^x pdf(x')dx', integral of the probability distribution function pdf), that is invertible (cdf*) produces random numbers r distributed according to pdf(x) out of uniform random numbers u with r=cdf*(u). If cdf is not known analytically, it might be worth the effort to use the rejection method, Num. Rec. p.290ff
| Nested Class Summary | |
|---|---|
static class |
PoissonRandom.MedianGauss
Class to take a normal-distributed variable, sort them, print the mean and the sigma. |
static class |
PoissonRandom.Poisson
Class to produce poisson distributed variable with the faster poisson method. |
static class |
PoissonRandom.SimulFits
Class to simulate a purely photon and/or shot-noise dominated fits image. |
static class |
PoissonRandom.TestGamma
Class to test the slow gammaSplit(a) method against the faster gamma method. |
static class |
PoissonRandom.TestPoisson
Class to test the slow poissonMM(a) method against the faster poisson method. |
| Field Summary | |
|---|---|
private static double |
ASPLIT
Use the splitting mechanism for gamma values lower than this. |
private static double |
BETA
Maximum of H/(G+H), p230. |
private static int |
C
Cut-off point. |
private static double |
D
Convenience convergence factor. |
private static double[] |
em
The numbers exp(-m). |
private static int |
L
Maximum order in qm. |
private static double |
LNPIBETA
Some constant involving beta and pi. |
private static int |
M
Maximum order for the propabilities pi. |
private static double[] |
pi
Probabilities pi = 1/e*sum(1/j!), j=0 to i. |
private static double[] |
qm
Center probabilities qm for m>= 9. |
private static double |
SQRT6
Square root from 6. |
private static double |
SQRT83
Square root from 8/3. |
| Constructor Summary | |
|---|---|
PoissonRandom()
Creates a new Poisson Random class with no special seed. |
|
PoissonRandom(long seed)
Creates a new Poisson Random class with special seed. |
|
| Method Summary | |
|---|---|
int |
binominal(double p,
int n)
Returns binominal distribution with bernoulli process. |
double |
gamma(double a)
Returns a gamma-distributed value. |
private double |
gammaFrac(double a)
Returns a gamma for a fraction smaller one. |
private double |
gammaInt(int a)
Returns gamma from an integer. |
double |
gammaSplit(double a)
Split a in an integer and a fractional part, calculate the two gammas separately and return sum. |
double |
poisson(double mu)
Creates a pseudo-poisson distributed value around the expectation value mu. |
static double |
poissonMM(double mu)
A simple method for poisson calculation, linear in mu |
| Methods inherited from class java.util.Random |
|---|
next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static double[] em
private static double[] qm
private static double[] pi
private static final int L
private static final int M
private static final int C
private static final double D
private static final double SQRT83
private static final double SQRT6
private static final double ASPLIT
private static final double BETA
private static final double LNPIBETA
| Constructor Detail |
|---|
public PoissonRandom()
public PoissonRandom(long seed)
| Method Detail |
|---|
public double poisson(double mu)
mu - The expected value.
public int binominal(double p,
int n)
public double gammaSplit(double a)
private double gammaInt(int a)
private double gammaFrac(double a)
public double gamma(double a)
public static double poissonMM(double mu)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||