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

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<Vector,Vector,MultinomialDistribution,DirichletDistribution>
              extended by gov.sandia.cognition.statistics.bayesian.conjugate.MultinomialBayesianEstimator
All Implemented Interfaces:
BatchAndIncrementalLearner<Vector,DirichletDistribution>, BatchLearner<Collection<? extends Vector>,DirichletDistribution>, IncrementalLearner<Vector,DirichletDistribution>, BayesianEstimator<Vector,Vector,DirichletDistribution>, BayesianEstimatorPredictor<Vector,Vector,DirichletDistribution>, ConjugatePriorBayesianEstimator<Vector,Vector,MultinomialDistribution,DirichletDistribution>, ConjugatePriorBayesianEstimatorPredictor<Vector,Vector,MultinomialDistribution,DirichletDistribution>, RecursiveBayesianEstimator<Vector,Vector,DirichletDistribution>, CloneableSerializable, Serializable, Cloneable

@PublicationReference(author="Wikipedia",
                      title="Conjugate Prior",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Conjugate_prior")
public class MultinomialBayesianEstimator
extends AbstractConjugatePriorBayesianEstimator<Vector,Vector,MultinomialDistribution,DirichletDistribution>
implements ConjugatePriorBayesianEstimatorPredictor<Vector,Vector,MultinomialDistribution,DirichletDistribution>

A Bayesian estimator for the parameters of a MultinomialDistribution using its conjugate prior distribution, the DirichletDistribution.

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

Nested Class Summary
static class MultinomialBayesianEstimator.Parameter
          Parameter of this conjugate prior relationship.
 
Field Summary
static int DEFAULT_NUM_CLASSES
          Default number of classes/labels, 2.
static int DEFAULT_NUM_TRIALS
          Default number of trials, 2.
 
Fields inherited from class gov.sandia.cognition.statistics.bayesian.conjugate.AbstractConjugatePriorBayesianEstimator
parameter
 
Constructor Summary
  MultinomialBayesianEstimator()
          Creates a new instance of MultinomialBayesianEstimator
protected MultinomialBayesianEstimator(BayesianParameter<Vector,MultinomialDistribution,DirichletDistribution> parameter)
          Creates a new instance
  MultinomialBayesianEstimator(DirichletDistribution initialBelief, int numTrials)
          Creates a new instance of MultinomialBayesianEstimator
  MultinomialBayesianEstimator(int numTrials)
          Creates a new instance of MultinomialBayesianEstimator
  MultinomialBayesianEstimator(int numClasses, int numTrials)
          Creates a new instance of MultinomialBayesianEstimator
  MultinomialBayesianEstimator(MultinomialDistribution conditional, DirichletDistribution prior)
          Creates a new instance of PoissonBayesianEstimator
 
Method Summary
 double computeEquivalentSampleSize(DirichletDistribution belief)
          Computes the equivalent sample size of using the given prior.
 MultinomialDistribution createConditionalDistribution(Vector parameter)
          Creates an instance of the class conditional distribution, parameterized by the given parameter value.
 MultinomialBayesianEstimator.Parameter createParameter(MultinomialDistribution conditional, DirichletDistribution prior)
          Creates a parameter linking the conditional and prior distributions
 MultivariatePolyaDistribution createPredictiveDistribution(DirichletDistribution posterior)
          Creates the predictive distribution of new data given the posterior.
 int getNumTrials()
          Getter for numTrials
 void setNumTrials(int numTrials)
          Setter for numTrials
 void update(DirichletDistribution belief, Vector value)
          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
clone, 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
getParameter
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.IncrementalLearner
createInitialLearnedObject, update
 

Field Detail

DEFAULT_NUM_TRIALS

public static final int DEFAULT_NUM_TRIALS
Default number of trials, 2.

See Also:
Constant Field Values

DEFAULT_NUM_CLASSES

public static final int DEFAULT_NUM_CLASSES
Default number of classes/labels, 2.

See Also:
Constant Field Values
Constructor Detail

MultinomialBayesianEstimator

public MultinomialBayesianEstimator()
Creates a new instance of MultinomialBayesianEstimator


MultinomialBayesianEstimator

public MultinomialBayesianEstimator(int numTrials)
Creates a new instance of MultinomialBayesianEstimator

Parameters:
numTrials - Number of trials in the distribution, must be greater than 0.

MultinomialBayesianEstimator

public MultinomialBayesianEstimator(int numClasses,
                                    int numTrials)
Creates a new instance of MultinomialBayesianEstimator

Parameters:
numClasses - Number of classes/labels/parameters
numTrials - Number of trials in the distribution, must be greater than 0.

MultinomialBayesianEstimator

public MultinomialBayesianEstimator(DirichletDistribution initialBelief,
                                    int numTrials)
Creates a new instance of MultinomialBayesianEstimator

Parameters:
initialBelief - Initial belief of the prior.
numTrials - Number of trials in the distribution, must be greater than 0.

MultinomialBayesianEstimator

public MultinomialBayesianEstimator(MultinomialDistribution conditional,
                                    DirichletDistribution prior)
Creates a new instance of PoissonBayesianEstimator

Parameters:
prior - Default conjugate prior.
conditional - Conditional distribution of the conjugate prior.

MultinomialBayesianEstimator

protected MultinomialBayesianEstimator(BayesianParameter<Vector,MultinomialDistribution,DirichletDistribution> parameter)
Creates a new instance

Parameters:
parameter - Bayesian hyperparameter relationship between the conditional distribution and the conjugate prior distribution.
Method Detail

createParameter

public MultinomialBayesianEstimator.Parameter createParameter(MultinomialDistribution conditional,
                                                              DirichletDistribution prior)
Description copied from interface: ConjugatePriorBayesianEstimator
Creates a parameter linking the conditional and prior distributions

Specified by:
createParameter in interface ConjugatePriorBayesianEstimator<Vector,Vector,MultinomialDistribution,DirichletDistribution>
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

computeEquivalentSampleSize

public double computeEquivalentSampleSize(DirichletDistribution 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<Vector,Vector,MultinomialDistribution,DirichletDistribution>
Parameters:
belief - Prior belief to measure.
Returns:
Equivalent sample size of the initial belief.

update

public void update(DirichletDistribution belief,
                   Vector value)
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<Vector,DirichletDistribution>
Parameters:
belief - The object to update.
value - The new data for the learning algorithm to use to update the object.

getNumTrials

public int getNumTrials()
Getter for numTrials

Returns:
Number of trials in the distribution, must be greater than 0.

setNumTrials

public void setNumTrials(int numTrials)
Setter for numTrials

Parameters:
numTrials - Number of trials in the distribution, must be greater than 0.

createConditionalDistribution

public MultinomialDistribution createConditionalDistribution(Vector parameter)
Description copied from interface: ConjugatePriorBayesianEstimator
Creates an instance of the class conditional distribution, parameterized by the given parameter value. This is the distribution that we implicitly draw observation samples from.

Specified by:
createConditionalDistribution in interface ConjugatePriorBayesianEstimator<Vector,Vector,MultinomialDistribution,DirichletDistribution>
Overrides:
createConditionalDistribution in class AbstractConjugatePriorBayesianEstimator<Vector,Vector,MultinomialDistribution,DirichletDistribution>
Parameters:
parameter - Parameter used to create the class conditional distribution.
Returns:
Parameterized class conditional distribution.

createPredictiveDistribution

public MultivariatePolyaDistribution createPredictiveDistribution(DirichletDistribution 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<Vector,Vector,DirichletDistribution>
Parameters:
posterior - Posterior distribution from which to compute the predictive posterior.
Returns:
Predictive distribution of new data given the observed data.