com.aliasi.stats
Class BernoulliDistribution

java.lang.Object
  extended by com.aliasi.stats.AbstractDiscreteDistribution
      extended by com.aliasi.stats.MultivariateDistribution
          extended by com.aliasi.stats.BernoulliDistribution
All Implemented Interfaces:
DiscreteDistribution
Direct Known Subclasses:
BernoulliConstant, BernoulliEstimator

public abstract class BernoulliDistribution
extends MultivariateDistribution

A BernoulliDistribution is a multivariate distribution with two outcomes, 0 (labeled "failure") and 1 (labeled "success"). A Bernoulli distribution is the basis of the binomial distribution.

For more information, see:

Since:
LingPipe2.0
Version:
2.0
Author:
Bob Carpenter

Field Summary
static String FAILURE_LABEL
          The label for dimension zero: "failure".
static String SUCCESS_LABEL
          The label for dimension one: "success".
 
Constructor Summary
BernoulliDistribution()
          Construct a Bernoulli distribution.
 
Method Summary
 String label(long outcome)
          Returns the failure label for outcome zero, and the success label for outcome one.
 long maxOutcome()
          Returns one, the maximum outcome for a Bernoulli distribution.
 int numDimensions()
          Returns two, the number of dimensions for a Bernoulli distribution.
 double probability(long outcome)
          Returns the probability of the specified outcome.
abstract  double successProbability()
          Returns the success probability for this distribution.
 double variance()
          Returns the variance of this Bernoulli distribution.
 
Methods inherited from class com.aliasi.stats.MultivariateDistribution
log2Probability, minOutcome, outcome, probability
 
Methods inherited from class com.aliasi.stats.AbstractDiscreteDistribution
cumulativeProbability, cumulativeProbabilityGreater, cumulativeProbabilityLess, entropy, log2Probability, mean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAILURE_LABEL

public static final String FAILURE_LABEL
The label for dimension zero: "failure".

See Also:
Constant Field Values

SUCCESS_LABEL

public static final String SUCCESS_LABEL
The label for dimension one: "success".

See Also:
Constant Field Values
Constructor Detail

BernoulliDistribution

public BernoulliDistribution()
Construct a Bernoulli distribution.

Method Detail

maxOutcome

public long maxOutcome()
Returns one, the maximum outcome for a Bernoulli distribution.

Specified by:
maxOutcome in interface DiscreteDistribution
Overrides:
maxOutcome in class MultivariateDistribution
Returns:
The long integer one.

numDimensions

public int numDimensions()
Returns two, the number of dimensions for a Bernoulli distribution.

Specified by:
numDimensions in class MultivariateDistribution
Returns:
Two, the number of dimensions for a Bernoulli distribution.

variance

public double variance()
Returns the variance of this Bernoulli distribution. Applying the general definition of variance to a Bernoulli distribution yields:
variance = P(success) * (1 - P(success))

Specified by:
variance in interface DiscreteDistribution
Overrides:
variance in class AbstractDiscreteDistribution
Returns:
The variance of this distribution.

probability

public double probability(long outcome)
Returns the probability of the specified outcome. This method is implemented to return one minus the success probability for outcome zero, the success probabilty for outcome one, and zero for all other outcomes.

Specified by:
probability in interface DiscreteDistribution
Specified by:
probability in class MultivariateDistribution
Parameters:
outcome - Outcome whose probability is returned.
Returns:
The probability of the specified outcome.

label

public String label(long outcome)
Returns the failure label for outcome zero, and the success label for outcome one. The label for zero is FAILURE_LABEL and the label for one is SUCCESS_LABEL respectively.

Overrides:
label in class MultivariateDistribution
Parameters:
outcome - Outcome whose label is returned.
Returns:
The label for the outcome.
Throws:
IllegalArgumentException - If the outcome is out of range.

successProbability

public abstract double successProbability()
Returns the success probability for this distribution. This method must be defined by concrete subclasses, and will be used to define probability(long).

Returns:
The probability of success for this distribution.