com.aliasi.stats

## Class BernoulliEstimator

• All Implemented Interfaces:
DiscreteDistribution, Compilable

```public class BernoulliEstimator
extends BernoulliDistribution
implements Compilable```
A `BernoulliEstimator` provides a maximum likelihood estimate of a Bernoulli distribution. Training samples are provided through the method `train(boolean,int)` specifying success or failure and the number of samples. An unbiased estimator for a Bernoulli distribution's probability of success is simply the percentage of successes.
Since:
LingPipe2.0
Version:
2.4
Author:
Bob Carpenter

• ### Fields inherited from class com.aliasi.stats.BernoulliDistribution

`FAILURE_LABEL, SUCCESS_LABEL`
• ### Constructor Summary

Constructors
Constructor and Description
`BernoulliEstimator()`
Construct a Bernoulli estimator with zero counts.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `compileTo(ObjectOutput objOut)`
Compiles this Bernoulli estimator to the specified object output.
`long` `numTrainingSamples()`
Returns the number of training samples provided for this estimator.
`long` `numTrainingSamples(boolean success)`
Returns the number of training samples for the specified outcome, success or failure.
`double` `successProbability()`
Returns the maximum likelihood estimate of success from the training samples provided.
`void` `train(boolean success)`
Trains the estimator with one sample that is specified as a success or failure.
`void` ```train(boolean success, int numSamples)```
Train this estimator with the specified number of samples for success or failure as specified.
• ### Methods inherited from class com.aliasi.stats.BernoulliDistribution

`label, maxOutcome, numDimensions, probability, variance`
• ### 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`
• ### Constructor Detail

• #### BernoulliEstimator

`public BernoulliEstimator()`
Construct a Bernoulli estimator with zero counts.
• ### Method Detail

• #### train

```public void train(boolean success,
int numSamples)```
Train this estimator with the specified number of samples for success or failure as specified.
Parameters:
`success` - A flag for whether the training samples are for success or failure.
`numSamples` - Number of samples to train.
• #### train

`public void train(boolean success)`
Trains the estimator with one sample that is specified as a success or failure.
Parameters:
`success` - Flag for whether the sample was a success or a failure.
• #### successProbability

`public double successProbability()`
Returns the maximum likelihood estimate of success from the training samples provided.
Specified by:
`successProbability` in class `BernoulliDistribution`
Returns:
The maximum likelihood estimate of success from the training samples provided.
• #### numTrainingSamples

`public long numTrainingSamples()`
Returns the number of training samples provided for this estimator.
Returns:
The number of training samples provided for this estimator.
• #### numTrainingSamples

`public long numTrainingSamples(boolean success)`
Returns the number of training samples for the specified outcome, success or failure.
Parameters:
`success` - Flag indicating whether outcome is success or failure.
Returns:
Count of training samples with specified success.
• #### compileTo

```public void compileTo(ObjectOutput objOut)
throws IOException```
Compiles this Bernoulli estimator to the specified object output. The corresponding read will produce an instance of `BernoulliConstant` with the same success probability as the estimate derived from this estimator.
Specified by:
`compileTo` in interface `Compilable`
Parameters:
`objOut` - Object output to which this Bernoulli distribution is written.
Throws:
`IOException` - If there is an I/O error compiling the object.