cc.mallet.types
Class Multinomial

java.lang.Object
  extended by cc.mallet.types.SparseVector
      extended by cc.mallet.types.FeatureVector
          extended by cc.mallet.types.Multinomial
All Implemented Interfaces:
AlphabetCarrying, ConstantMatrix, Vector, java.io.Serializable
Direct Known Subclasses:
Multinomial.Logged

public class Multinomial
extends FeatureVector

A probability distribution over a set of features represented as a FeatureVector. The values associated with each element in the Multinomial/FeaturVector are probabilities and should sum to 1. Features are indexed using feature indices - the index into the underlying Alphabet - rather than using locations the way FeatureVectors do.

Multinomial.Estimator provides a subhierachy of ways to generate an estimate of the probability distribution from counts associated with the features.

Author:
Andrew McCallum mccallum@cs.umass.edu
See Also:
Serialized Form

Nested Class Summary
static class Multinomial.Estimator
          A hierarchy of classes used to produce estimates of probabilities, in the form of a Multinomial, from counts associated with the elements of an Alphabet.
static class Multinomial.LaplaceEstimator
          An MEstimator with m set to 1.
static class Multinomial.Logged
          A Multinomial in which the values associated with each feature index fi is Math.log(probability[fi]) instead of probability[fi].
static class Multinomial.MAPEstimator
          Unimplemented, but the MEstimators are.
static class Multinomial.MEstimator
          An Estimator in which probability estimates in a Multinomial are generated by adding a constant m (specified at construction time) to each count before dividing by the total of the m-biased counts.
static class Multinomial.MLEstimator
          An MEstimator with m set to 0.
 
Field Summary
 
Fields inherited from class cc.mallet.types.SparseVector
hasInfinite, indices, values
 
Constructor Summary
  Multinomial(double[] probabilities)
           
  Multinomial(double[] probabilities, Alphabet dictionary)
           
protected Multinomial(double[] probabilities, Alphabet dictionary, int size, boolean copy, boolean checkSum)
           
  Multinomial(double[] probabilities, int size)
           
 
Method Summary
 void addProbabilitiesTo(double[] vector)
           
 Alphabet getAlphabet()
           
 double logProbability(int featureIndex)
           
 double logProbability(java.lang.Object key)
           
 double probability(int featureIndex)
           
 double probability(java.lang.Object key)
           
 FeatureSequence randomFeatureSequence(Randoms r, int length)
           
 FeatureVector randomFeatureVector(Randoms r, int size)
           
 int randomIndex(Randoms r)
           
 java.lang.Object randomObject(Randoms r)
           
 int size()
           
 
Methods inherited from class cc.mallet.types.FeatureVector
alphabetsMatch, cloneMatrix, cloneMatrixZeroed, contains, getAlphabets, getObjectIndices, location, newFeatureVector, toSimpFile, toString, toString, value
 
Methods inherited from class cc.mallet.types.SparseVector
absNorm, addTo, addTo, arrayCopyFrom, arrayCopyFrom, arrayCopyInto, dotProduct, dotProduct, dotProduct, dotProduct, extendedDotProduct, extendedDotProduct, getDimensions, getIndices, getNumDimensions, getValues, incrementValue, indexAtLocation, infinityNorm, isBinary, isInfinite, isNaN, isNaNOrInfinite, location, makeBinary, makeNonBinary, map, numLocations, oneNorm, plusEqualsSparse, plusEqualsSparse, print, removeDuplicates, setAll, setValue, setValueAtLocation, singleIndex, singleSize, singleToIndices, singleValue, sortIndices, timesEquals, timesEqualsSparse, timesEqualsSparse, timesEqualsSparseZero, twoNorm, value, value, valueAtLocation, vectorAdd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Multinomial

protected Multinomial(double[] probabilities,
                      Alphabet dictionary,
                      int size,
                      boolean copy,
                      boolean checkSum)

Multinomial

public Multinomial(double[] probabilities,
                   Alphabet dictionary)

Multinomial

public Multinomial(double[] probabilities,
                   int size)

Multinomial

public Multinomial(double[] probabilities)
Method Detail

size

public int size()

probability

public double probability(int featureIndex)

probability

public double probability(java.lang.Object key)

logProbability

public double logProbability(int featureIndex)

logProbability

public double logProbability(java.lang.Object key)

getAlphabet

public Alphabet getAlphabet()
Specified by:
getAlphabet in interface AlphabetCarrying
Overrides:
getAlphabet in class FeatureVector

addProbabilitiesTo

public void addProbabilitiesTo(double[] vector)

randomIndex

public int randomIndex(Randoms r)

randomObject

public java.lang.Object randomObject(Randoms r)

randomFeatureSequence

public FeatureSequence randomFeatureSequence(Randoms r,
                                             int length)

randomFeatureVector

public FeatureVector randomFeatureVector(Randoms r,
                                         int size)