|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.unihalle.informatik.MiToBo.math.distributions.impl.GenericDiscreteDistribution
public class GenericDiscreteDistribution
A generic discrete distribution
Field Summary | |
---|---|
protected double[] |
cdf
cumulative distribution function, used for sampling |
private boolean |
LOG
Tells if the distribution is internally represented by the natural logarithm of the probability values |
protected double[] |
pmf
probability mass function |
protected java.util.Random |
rand
|
Constructor Summary | |
---|---|
GenericDiscreteDistribution(double[] weights,
java.util.Random rand)
Constructor. |
|
GenericDiscreteDistribution(double[] weights,
java.util.Random rand,
boolean weightsAreLog)
Constructor. |
Method Summary | |
---|---|
java.lang.Integer |
drawSample()
Generate a new sample from this density. |
double |
log_p(java.lang.Integer k)
Evaluate natural logarithm of p(X) at location x. log(P(X=x)) |
double |
p(java.lang.Integer k)
Evaluate p(X) at location x. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double[] cdf
private boolean LOG
protected double[] pmf
protected java.util.Random rand
Constructor Detail |
---|
public GenericDiscreteDistribution(double[] weights, java.util.Random rand)
weigths.length-1
.
Weights must not sum to 0 and must not be negative. If weights do not sum to 1, they get normalized.
weights
- proportional to the probabilities of events 0 to weigths.length-1
.rand
- a random generator used for samplingpublic GenericDiscreteDistribution(double[] weights, java.util.Random rand, boolean weightsAreLog)
weigths.length-1
.
If so, (log-)weights must not sum to Double.NEGATIVE_INFINITY
. If (log-)weights do not sum to 0, they get normalized.
If weights are not logarithms of probabilities, see GenericDiscreteDistribution(double[] weights, Random rand)
.
weights
- (the natural logarithm of values proportional to) the probabilities of events 0 to weigths.length-1
.rand
- a random generator used for samplingweightsAreLog
- determines if weights are interpreted as log probabilitiesMethod Detail |
---|
public java.lang.Integer drawSample()
SamplingDistribution
drawSample
in interface SamplingDistribution<java.lang.Integer>
public double log_p(java.lang.Integer k)
LogEvaluatableDistribution
log_p
in interface LogEvaluatableDistribution<java.lang.Integer>
k
- realization of random variable X
public double p(java.lang.Integer k)
EvaluatableDistribution
p
in interface EvaluatableDistribution<java.lang.Integer>
k
- realization of random variable X
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 |