public abstract class AbstractDiscreteDistribution extends Object implements DiscreteDistribution
AbstractDiscreteDistribution
provides a default
abstract implementation of discrete distributions. Concrete
subclasses need only implement the probability(long)
method, which returns the probability for each outcome.
The method minOutcome()
and maxOutcome()
bound
the range of nonzero probabilities. They default to Long.MIN_VALUE
and Long.MAX_VALUE
respectively. Concrete
subclasses should implement the tightest possible bounds for these
methods, because cumulative probabilities, means, variances and
entropies are implemented by looping between the minimum and
maximum values and evaluating the probability at each point.
Constructor and Description 

AbstractDiscreteDistribution()
Construct an abstract discrete distribution.

Modifier and Type  Method and Description 

double 
cumulativeProbability(long lowerBound,
long upperBound)
Returns the cumulative probability of all outcomes between the
specified bounds, inclusive.

double 
cumulativeProbabilityGreater(long lowerBound)
Returns the cumulative probability of all outcomes greater than
or equal to the specified lower bound.

double 
cumulativeProbabilityLess(long upperBound)
Returns the cumulative probability of all outcomes less
than or equal to the specified upper bound.

double 
entropy()
Returns the entropy of this distribution in bits (log 2).

double 
log2Probability(long outcome)
Returns the log (base 2) probability of the specified outcome.

long 
maxOutcome()
Returns the maximum outcome with nonzero probability for this
distribution.

double 
mean()
Returns the mean of this distribution.

long 
minOutcome()
Returns the minimum outcome with nonzero probability for this
distribution.

abstract double 
probability(long outcome)
Returns the probability of the specified outcome in this
distribution.

double 
variance()
Returns the variance of this distribution.

public AbstractDiscreteDistribution()
public abstract double probability(long outcome)
probability
in interface DiscreteDistribution
outcome
 Outcome whose probability is returned.public double cumulativeProbabilityLess(long upperBound)
cumulativeProbabilityLess
in interface DiscreteDistribution
upperBound
 Upper bound of outcome.public double cumulativeProbabilityGreater(long lowerBound)
cumulativeProbabilityGreater
in interface DiscreteDistribution
lowerBound
 Lower bound on outcomes.public double cumulativeProbability(long lowerBound, long upperBound)
cumulativeProbability
in interface DiscreteDistribution
lowerBound
 Lower bound of outcome set.upperBound
 Upper bound of outcome set.public double log2Probability(long outcome)
log2Probability
in interface DiscreteDistribution
outcome
 Outcome whose log probability is returned.public long minOutcome()
Long.MIN_VALUE
. If possible, concrete subclasses should
override this method with a tighter bound.minOutcome
in interface DiscreteDistribution
public long maxOutcome()
Long.MAX_VALUE
. If possible, concrete subclasses should
override this method with a tighter bound.maxOutcome
in interface DiscreteDistribution
public double mean()
mean
in interface DiscreteDistribution
public double variance()
variance
in interface DiscreteDistribution
public double entropy()
H(P) =  Σ_{x}
P(x) * log_{2} P(x)
This method is implemented by iterating over the outcomes
between the minimum and maximum and summing their negative
probability weighted log probabilities.entropy
in interface DiscreteDistribution