gov.sandia.cognition.statistics.bayesian.conjugate
Class BinomialBayesianEstimator

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.AbstractBatchAndIncrementalLearner<ObservationType,BeliefType>
          extended by gov.sandia.cognition.statistics.bayesian.conjugate.AbstractConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>
              extended by gov.sandia.cognition.statistics.bayesian.conjugate.BinomialBayesianEstimator
All Implemented Interfaces:
BatchAndIncrementalLearner<Number,BetaDistribution>, BatchLearner<Collection<? extends Number>,BetaDistribution>, IncrementalLearner<Number,BetaDistribution>, BayesianEstimator<Number,Double,BetaDistribution>, BayesianEstimatorPredictor<Number,Double,BetaDistribution>, ConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>, ConjugatePriorBayesianEstimatorPredictor<Number,Double,BinomialDistribution,BetaDistribution>, RecursiveBayesianEstimator<Number,Double,BetaDistribution>, CloneableSerializable, Serializable, Cloneable

public class BinomialBayesianEstimator
extends AbstractConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>
implements ConjugatePriorBayesianEstimatorPredictor<Number,Double,BinomialDistribution,BetaDistribution>

A Bayesian estimator for the parameter of a Bernoulli parameter, p, of a BinomialDistribution using the conjugate prior BetaDistribution.

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class BinomialBayesianEstimator.Parameter
          Parameter of this relationship
 
Field Summary
static int DEFAULT_N
          Default n, 1.
 
Fields inherited from class gov.sandia.cognition.statistics.bayesian.conjugate.AbstractConjugatePriorBayesianEstimator
parameter
 
Constructor Summary
  BinomialBayesianEstimator()
          Creates a new instance of BinomialBayesianEstimator
protected BinomialBayesianEstimator(BayesianParameter<Double,BinomialDistribution,BetaDistribution> parameter)
          Creates a new instance of BinomialBayesianEstimator
  BinomialBayesianEstimator(BinomialDistribution conditional, BetaDistribution prior)
          Creates a new instance of BinomialBayesianEstimator
  BinomialBayesianEstimator(int n)
          Creates a new instance of BinomialBayesianEstimator
  BinomialBayesianEstimator(int n, BetaDistribution prior)
          Creates a new instance of BinomialBayesianEstimator
 
Method Summary
 BinomialBayesianEstimator clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 double computeEquivalentSampleSize(BetaDistribution belief)
          Computes the equivalent sample size of using the given prior.
 BinomialBayesianEstimator.Parameter createParameter(BinomialDistribution conditional, BetaDistribution prior)
          Creates a parameter linking the conditional and prior distributions
 BetaBinomialDistribution createPredictiveDistribution(BetaDistribution posterior)
          Creates the predictive distribution of new data given the posterior.
 int getN()
          Gets the number of samples in the experiment
 void setN(int n)
          Sets the number of samples in the experiment
 void update(BetaDistribution target, Number data)
          The update method updates an object of ResultType using the given new data of type DataType, using some form of "learning" algorithm.
 
Methods inherited from class gov.sandia.cognition.statistics.bayesian.conjugate.AbstractConjugatePriorBayesianEstimator
createConditionalDistribution, createInitialLearnedObject, getInitialBelief, getParameter, setParameter
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchAndIncrementalLearner
learn, learn, update
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.bayesian.conjugate.ConjugatePriorBayesianEstimator
createConditionalDistribution, getParameter
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.IncrementalLearner
createInitialLearnedObject, update
 

Field Detail

DEFAULT_N

public static final int DEFAULT_N
Default n, 1.

See Also:
Constant Field Values
Constructor Detail

BinomialBayesianEstimator

public BinomialBayesianEstimator()
Creates a new instance of BinomialBayesianEstimator


BinomialBayesianEstimator

public BinomialBayesianEstimator(int n)
Creates a new instance of BinomialBayesianEstimator

Parameters:
n - Samples in the experiment, must be greater than zero

BinomialBayesianEstimator

public BinomialBayesianEstimator(int n,
                                 BetaDistribution prior)
Creates a new instance of BinomialBayesianEstimator

Parameters:
n - Samples in the experiment, must be greater than zero
prior - Conjugate prior of the conditional for the parameter

BinomialBayesianEstimator

public BinomialBayesianEstimator(BinomialDistribution conditional,
                                 BetaDistribution prior)
Creates a new instance of BinomialBayesianEstimator

Parameters:
conditional - Distribution that generates the observations
prior - Conjugate prior of the conditional for the parameter

BinomialBayesianEstimator

protected BinomialBayesianEstimator(BayesianParameter<Double,BinomialDistribution,BetaDistribution> parameter)
Creates a new instance of BinomialBayesianEstimator

Parameters:
parameter - Parameter that describes the relationship between the conditional and the conjugate prior
Method Detail

createParameter

public BinomialBayesianEstimator.Parameter createParameter(BinomialDistribution conditional,
                                                           BetaDistribution prior)
Description copied from interface: ConjugatePriorBayesianEstimator
Creates a parameter linking the conditional and prior distributions

Specified by:
createParameter in interface ConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>
Parameters:
conditional - Distribution from which observations are generated
prior - Distribution that generates parameters for the conditional
Returns:
Parameter describing the relationship between the conditional and prior

clone

public BinomialBayesianEstimator clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>
Returns:
A clone of this object.

update

public void update(BetaDistribution target,
                   Number data)
Description copied from interface: IncrementalLearner
The update method updates an object of ResultType using the given new data of type DataType, using some form of "learning" algorithm.

Specified by:
update in interface IncrementalLearner<Number,BetaDistribution>
Parameters:
target - The object to update.
data - The new data for the learning algorithm to use to update the object.

computeEquivalentSampleSize

public double computeEquivalentSampleSize(BetaDistribution belief)
Description copied from interface: ConjugatePriorBayesianEstimator
Computes the equivalent sample size of using the given prior. This is effectively how many samples of bias the prior injects into the estimate.

Specified by:
computeEquivalentSampleSize in interface ConjugatePriorBayesianEstimator<Number,Double,BinomialDistribution,BetaDistribution>
Parameters:
belief - Prior belief to measure.
Returns:
Equivalent sample size of the initial belief.

createPredictiveDistribution

public BetaBinomialDistribution createPredictiveDistribution(BetaDistribution posterior)
Description copied from interface: BayesianEstimatorPredictor
Creates the predictive distribution of new data given the posterior. This is equivalent to evaluating the integral of: p( newdata | data ) = integral( conditional( newdata | data, parameters ) * p( parameters | data ) dparameters )

Specified by:
createPredictiveDistribution in interface BayesianEstimatorPredictor<Number,Double,BetaDistribution>
Parameters:
posterior - Posterior distribution from which to compute the predictive posterior.
Returns:
Predictive distribution of new data given the observed data.

getN

public int getN()
Gets the number of samples in the experiment

Returns:
Samples in the experiment, must be greater than zero

setN

public void setN(int n)
Sets the number of samples in the experiment

Parameters:
n - Samples in the experiment, must be greater than zero