com.aliasi.stats
Class PoissonEstimator

java.lang.Object
  extended by com.aliasi.stats.AbstractDiscreteDistribution
      extended by com.aliasi.stats.PoissonDistribution
          extended by com.aliasi.stats.PoissonEstimator
All Implemented Interfaces:
DiscreteDistribution

public class PoissonEstimator
extends PoissonDistribution

A PoissonEstimator implements the maximum likelihood Poisson distribution given training events. The training events are simply in the form of long integer outcomes. The rate parameter for the unbiased maximum likelihood estimator is given by the mean of the training samples. likelihood unbiased estimator

If there have been no training events, or if all training events have 0 values, an illegal state exception is thrown by lambda() and log2Prob().

The method compileTo(ObjectOutput) writes a compiled version of this distribution to the specified output. Reading it back in will produce a constant extension of PoissonDistribution. Poisson estimators are also serializable and the estimator read back in will have the same state as the one written out.

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

Constructor Summary
PoissonEstimator()
          Construct a Poisson estimator.
PoissonEstimator(double priorNumSamples, double priorMean)
          Construct a Poisson estimator with a prior set by the specified number of samples and mean value.
 
Method Summary
 void compileTo(ObjectOutput objOut)
          Writes a constant Poisson distribution with the same mean as the current value of this Poisson distribution's mean.
 double mean()
          Returns the mean for this estimator.
 void train(long sample)
          Add the specified sample to the collection of training data.
 void train(long sample, double weight)
          Add the specified sample to the collection of training data with the specified weight.
 
Methods inherited from class com.aliasi.stats.PoissonDistribution
log2Probability, minOutcome, probability, variance
 
Methods inherited from class com.aliasi.stats.AbstractDiscreteDistribution
cumulativeProbability, cumulativeProbabilityGreater, cumulativeProbabilityLess, entropy, maxOutcome
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoissonEstimator

public PoissonEstimator()
Construct a Poisson estimator.


PoissonEstimator

public PoissonEstimator(double priorNumSamples,
                        double priorMean)
Construct a Poisson estimator with a prior set by the specified number of samples and mean value. The combined effect will be as if the specified number of samples had be trained resulting the specified mean. Further training instances add to the

Parameters:
priorNumSamples - The initial number of samples given by the prior.
priorMean - The initial mean.
Throws:
IllegalArgumentException - If either number is not positive and finite.
Method Detail

train

public void train(long sample)
Add the specified sample to the collection of training data. The sample must be a number greater than or equal to zero. If adding the sample to the running sum would cause overflow, it is not added and an illegal state exception is thrown instead. If overflow is a problem, samples and the resulting rates may be scaled down.

Parameters:
sample - Sample to add to the training data.
Throws:
IllegalArgumentException - If the sample is less than
IllegalStateException - If the sample would overflow the running sum of samples.

train

public void train(long sample,
                  double weight)
Add the specified sample to the collection of training data with the specified weight. The sample must be a number greater than or equal to zero. Training weights must be greater than zero and not infinite.

If adding the sample to the running sum would cause overflow, it is not added and an illegal state exception is thrown instead. If overflow is a problem, samples and the resulting rates may be scaled down.

Parameters:
sample - Sample to add to the training data.
Throws:
IllegalArgumentException - If the sample is less than
IllegalStateException - If the sample would overflow the running sum of samples.

mean

public double mean()
Returns the mean for this estimator. This is simply the mean of the training samples.

Specified by:
mean in interface DiscreteDistribution
Specified by:
mean in class PoissonDistribution
Returns:
Rate parameter for this distribution.
Throws:
IllegalStateException - If there have been no training instances or all training instances had value 0, an illegal state exception is thrown.

compileTo

public void compileTo(ObjectOutput objOut)
               throws IOException
Writes a constant Poisson distribution with the same mean as the current value of this Poisson distribution's mean.

Parameters:
objOut - Object output to which a compiled version of this distribution is written.
Throws:
IllegalStateException - If there have been no training instances or all training instances had value 0, an illegal state exception is thrown.
IOException