|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Utility.RandomNumber | +--Utility.Geometric
Geometric is used to generate random variables from the
geometric distribution. The random variable represents
the position of the the first success in an infinite
sequence of Bernoulli trials. The probability of success
of each trial is identical and is given by fProbSuccess.
This value is passed
to the constructor to initialize the object.
This algorithm is kind of slow if p is very small since we have to
keep running trials until we observe a success. If p = 0.0001, this
could take quite a while ...
See Knuth Vol 2 for a faster algorithm using logarithms.
This is a discrete distribution.
Tests Performed
1000 samples were generated and the means and variances
were examined. Subjectively, they seemed correct.
A goodness of fit test was performed with 100 samples
and 10 intervals. It succeeded about 19/20 times.
Constructor Summary | |
Geometric(double probSuccess)
|
Method Summary | |
double |
sampleDouble()
Draw a random sample. |
int |
sampleInt()
Generate a geometrically distributed random variable. |
Methods inherited from class Utility.RandomNumber |
goodnessOfFitTest, goodnessOfFitTest, randomMixer, resetRandomMixer, sample01 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Geometric(double probSuccess)
Method Detail |
public int sampleInt()
sampleInt
in class RandomNumber
Geometric(double)
public double sampleDouble()
RandomNumber
sampleDouble
in class RandomNumber
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |