|
||||||||||
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
@ALDMetaInfo(export=ALLOWED) public class GenericDiscreteDistribution
A generic discrete distribution
Field Summary | |
---|---|
protected double[] |
cdf
cumulative distribution function, used for sampling |
protected double[] |
pmf
probability mass function |
protected Random |
rand
|
Constructor Summary | |
---|---|
GenericDiscreteDistribution(double[] weights,
Random rand)
Constructor. |
|
GenericDiscreteDistribution(double[] weights,
Random rand,
boolean weightsAreLog)
Constructor. |
Method Summary | |
---|---|
Integer |
drawSample()
Generate a new sample from this density. |
double |
log_p(Integer k)
Evaluate natural logarithm of p(X) at location x. log(P(X=x)) |
double |
p(Integer k)
Evaluate p(X) at location x. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Random rand
protected double[] pmf
protected double[] cdf
Constructor Detail |
---|
public GenericDiscreteDistribution(double[] weights, 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, 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 double p(Integer k)
EvaluatableDistribution
p
in interface EvaluatableDistribution<Integer>
k
- realization of random variable X
public double log_p(Integer k)
LogEvaluatableDistribution
log_p
in interface LogEvaluatableDistribution<Integer>
k
- realization of random variable X
public Integer drawSample()
SamplingDistribution
drawSample
in interface SamplingDistribution<Integer>
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |