gov.sandia.cognition.statistics.distribution
Class MultinomialDistribution

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.AbstractDistribution<Vector>
          extended by gov.sandia.cognition.statistics.distribution.MultinomialDistribution
All Implemented Interfaces:
Vectorizable, ClosedFormComputableDiscreteDistribution<Vector>, ClosedFormComputableDistribution<Vector>, ClosedFormDistribution<Vector>, ComputableDistribution<Vector>, DiscreteDistribution<Vector>, Distribution<Vector>, DistributionWithMean<Vector>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
MultinomialDistribution.PMF

@PublicationReference(author="Wikipedia",
                      title="Multinomial distribution",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Multinomial_distribution")
public class MultinomialDistribution
extends AbstractDistribution<Vector>
implements ClosedFormComputableDiscreteDistribution<Vector>

A multinomial distribution is the multivariate/multiclass generalization of the Binomial distribution. That is, the PMF returns the probability of from "numTrials" trials of selecting from "numClasses" classes with the probabilities p1,p2,...p_numClasses. In our class, the probability parameters must be positive but do not have to sum to one because we normalize by the L1 norm.

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

Nested Class Summary
static class MultinomialDistribution.Domain
          Allows the iteration through the set of subsets.
static class MultinomialDistribution.PMF
          Probability Mass Function of the Multinomial Distribution.
 
Field Summary
static int DEFAULT_NUM_CLASSES
          Default number of classes (labels or parameters), 2.
static int DEFAULT_NUM_TRIALS
          Default number of trials, 1.
 
Constructor Summary
MultinomialDistribution()
          Creates a new instance of MultinomialDistribution
MultinomialDistribution(int numClasses, int numTrials)
          Creates a new instance of MultinomialDistribution
MultinomialDistribution(MultinomialDistribution other)
          Copy constructor
MultinomialDistribution(Vector parameters, int numTrials)
          Creates a new instance of MultinomialDistribution
 
Method Summary
 MultinomialDistribution clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
 MultinomialDistribution.Domain getDomain()
          Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution
 int getDomainSize()
          Gets the size of the domain.
 Vector getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 int getNumTrials()
          Getter for numTrials
 Vector getParameters()
          Getter for parameters
 MultinomialDistribution.PMF getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 ArrayList<Vector> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
 void setNumTrials(int numTrials)
          Setter for numTrials
 void setParameters(Vector parameters)
          Setter for parameters
 
Methods inherited from class gov.sandia.cognition.statistics.AbstractDistribution
sample
 
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.Distribution
sample
 

Field Detail

DEFAULT_NUM_CLASSES

public static final int DEFAULT_NUM_CLASSES
Default number of classes (labels or parameters), 2.

See Also:
Constant Field Values

DEFAULT_NUM_TRIALS

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

See Also:
Constant Field Values
Constructor Detail

MultinomialDistribution

public MultinomialDistribution()
Creates a new instance of MultinomialDistribution


MultinomialDistribution

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

Parameters:
numClasses - Number of classes (labels or parameters) to use.
numTrials - Number of trials in the distribution, must be greater than 0.

MultinomialDistribution

public MultinomialDistribution(Vector parameters,
                               int numTrials)
Creates a new instance of MultinomialDistribution

Parameters:
numTrials - Number of trials in the distribution, must be greater than 0.
parameters - Parameters of the multinomial distribution, must be at least 2-dimensional and each element must be nonnegative.

MultinomialDistribution

public MultinomialDistribution(MultinomialDistribution other)
Copy constructor

Parameters:
other - MultinomialDistribution to copy
Method Detail

clone

public MultinomialDistribution 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 Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

getParameters

public Vector getParameters()
Getter for parameters

Returns:
Parameters of the multinomial distribution, must be at least 2-dimensional and each element must be nonnegative.

setParameters

public void setParameters(Vector parameters)
Setter for parameters

Parameters:
parameters - Parameters of the multinomial distribution, must be at least 2-dimensional and each element must be nonnegative.

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

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.

getMean

public Vector getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.

Specified by:
getMean in interface DistributionWithMean<Vector>
Returns:
Mean of the distribution.

sample

public ArrayList<Vector> sample(Random random,
                                int numSamples)
Description copied from interface: Distribution
Draws multiple random samples from the distribution. It is generally more efficient to use this multiple-sample method than multiple calls of the single-sample method. (But not always.)

Specified by:
sample in interface Distribution<Vector>
Parameters:
random - Random-number generator to use in order to generate random numbers.
numSamples - Number of samples to draw from the distribution.
Returns:
Samples drawn according to this distribution.

getDomain

public MultinomialDistribution.Domain getDomain()
Description copied from interface: DiscreteDistribution
Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution

Specified by:
getDomain in interface DiscreteDistribution<Vector>
Returns:
Collection that enumerates each value that the domain can take

getDomainSize

public int getDomainSize()
Description copied from interface: DiscreteDistribution
Gets the size of the domain.

Specified by:
getDomainSize in interface DiscreteDistribution<Vector>
Returns:
The size of the domain.

getProbabilityFunction

public MultinomialDistribution.PMF getProbabilityFunction()
Description copied from interface: ComputableDistribution
Gets the distribution function associated with this Distribution, either the PDF or PMF.

Specified by:
getProbabilityFunction in interface ComputableDistribution<Vector>
Specified by:
getProbabilityFunction in interface DiscreteDistribution<Vector>
Returns:
Distribution function associated with this Distribution.