@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>
Modifier and Type | Class and Description |
---|---|
static class |
MultinomialDistribution.Domain
Allows the iteration through the set of subsets.
|
static class |
MultinomialDistribution.PMF
Probability Mass Function of the Multinomial Distribution.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NUM_CLASSES
Default number of classes (labels or parameters), 2.
|
static int |
DEFAULT_NUM_TRIALS
Default number of trials, 1.
|
Constructor and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super Vector> output)
Draws multiple random samples from the distribution and puts the result
into the given collection.
|
void |
setNumTrials(int numTrials)
Setter for numTrials
|
void |
setParameters(Vector parameters)
Setter for parameters
|
sample, sample
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sample, sample
public static final int DEFAULT_NUM_CLASSES
public static final int DEFAULT_NUM_TRIALS
public MultinomialDistribution()
public MultinomialDistribution(int numClasses, int numTrials)
numClasses
- Number of classes (labels or parameters) to use.numTrials
- Number of trials in the distribution, must be greater than 0.public MultinomialDistribution(Vector parameters, int numTrials)
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.public MultinomialDistribution(MultinomialDistribution other)
other
- MultinomialDistribution to copypublic MultinomialDistribution clone()
AbstractCloneableSerializable
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.clone
in interface Vectorizable
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public Vector getParameters()
public void setParameters(Vector parameters)
parameters
- Parameters of the multinomial distribution, must be at least
2-dimensional and each element must be nonnegative.public Vector convertToVector()
Vectorizable
convertToVector
in interface Vectorizable
public void convertFromVector(Vector parameters)
Vectorizable
convertFromVector
in interface Vectorizable
parameters
- The parameters to incorporate.public int getNumTrials()
public void setNumTrials(int numTrials)
numTrials
- Number of trials in the distribution, must be greater than 0.public Vector getMean()
DistributionWithMean
getMean
in interface DistributionWithMean<Vector>
public void sampleInto(java.util.Random random, int sampleCount, java.util.Collection<? super Vector> output)
Distribution
sampleInto
in interface Distribution<Vector>
random
- Random number generator to use.sampleCount
- The number of samples to draw. Cannot be negative.output
- The collection to add the samples into.public MultinomialDistribution.Domain getDomain()
DiscreteDistribution
getDomain
in interface DiscreteDistribution<Vector>
public int getDomainSize()
DiscreteDistribution
getDomainSize
in interface DiscreteDistribution<Vector>
public MultinomialDistribution.PMF getProbabilityFunction()
ComputableDistribution
getProbabilityFunction
in interface ComputableDistribution<Vector>
getProbabilityFunction
in interface DiscreteDistribution<Vector>