|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object common.Multinomial
public class Multinomial
A distribution over a finite set of elements 0, 1, ..., k, specified with an array of k probabilities pi_0,...,pi_k summing to 1.
Constructor Summary | |
---|---|
Multinomial(double[] pi)
Creates a Multinomial object with probabilities specified by the given array. |
|
Multinomial(int k)
Creates a Multinomial object representing the uniform distribution over k elements. |
Method Summary | |
---|---|
void |
collectAggrStats(int i,
int n)
Records n occurrences of an element i, for use in updating parameters. |
void |
collectStats(int i)
Records an occurrence of element i, for use in updating parameters. |
double |
getLogProb(int i)
Returns the log of the probability of element i. |
double |
getProb(int i)
Returns the probability of element i. |
int |
sample()
Returns an integer chosen at random according to this distribution. |
int |
size()
Returns the size of the set that this distribution is defined over. |
double |
updateParams()
Sets the parameter array pi to the values that maximize the likelihood of the elements passed to collectStats since the last call to updateParams. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Multinomial(int k)
public Multinomial(double[] pi)
java.lang.IllegalArgumentException
- if pi does not define a probability
distributionMethod Detail |
---|
public int size()
public double getProb(int i)
getProb
in interface IntegerDist
public double getLogProb(int i)
getLogProb
in interface IntegerDist
public void collectStats(int i)
public void collectAggrStats(int i, int n)
public double updateParams()
public int sample()
sample
in interface IntegerDist
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |