|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sourceforge.jabm.prng.DiscreteProbabilityDistribution
public class DiscreteProbabilityDistribution
A class representing a discrete probability distribution which can used to generate random events according to the specified distribution. The output from a uniform PRNG is used to to select from the different possible events.
![]() |
![]() |
| Nested Class Summary | |
|---|---|
class |
DiscreteProbabilityDistribution.ProbabilityActionPair
|
static class |
DiscreteProbabilityDistribution.ProbabilityError
|
| Field Summary | |
|---|---|
protected int |
n
The number of possible events for this distribution. |
protected java.util.TreeSet<DiscreteProbabilityDistribution.ProbabilityActionPair> |
p
The probability distribution. |
protected cern.jet.random.engine.RandomEngine |
prng
|
protected java.util.TreeMap<java.lang.Integer,java.lang.Double> |
reverseMap
|
| Constructor Summary | |
|---|---|
DiscreteProbabilityDistribution(cern.jet.random.engine.RandomEngine prng,
double[] p)
|
|
DiscreteProbabilityDistribution(cern.jet.random.engine.RandomEngine prng,
int n)
Construct a new distribution with k possible events. |
|
| Method Summary | |
|---|---|
double |
computeMean()
Compute the expected value of the random variable defined by this distribution. |
int |
generateRandomEvent()
Generate a random event according to the probability distribution. |
int |
getN()
|
double |
getProbability(int i)
Get the probability of the ith event. |
double |
getSum()
|
void |
initialise()
|
void |
initialise(double[] probs)
|
void |
reset()
Reinitialise our state to the original settings. |
void |
setProbability(int i,
double probability)
Set the probability of the ith event. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.TreeSet<DiscreteProbabilityDistribution.ProbabilityActionPair> p
protected java.util.TreeMap<java.lang.Integer,java.lang.Double> reverseMap
protected int n
protected cern.jet.random.engine.RandomEngine prng
| Constructor Detail |
|---|
public DiscreteProbabilityDistribution(cern.jet.random.engine.RandomEngine prng,
int n)
k - The number of possible events for this random variable
public DiscreteProbabilityDistribution(cern.jet.random.engine.RandomEngine prng,
double[] p)
| Method Detail |
|---|
public void initialise()
public void initialise(double[] probs)
public void setProbability(int i,
double probability)
i - The eventprobability - The probability of event i occuringpublic double getProbability(int i)
i - The eventpublic int generateRandomEvent()
public double getSum()
public void reset()
Resetable
reset in interface Resetablepublic double computeMean()
public int getN()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||