@PublicationReference(author="Wikipedia", title="Categoical Distribution", type=WebPage, year=2011, url="http://en.wikipedia.org/wiki/Categorical_distribution") public class CategoricalDistribution extends AbstractDistribution<Vector> implements ClosedFormComputableDiscreteDistribution<Vector>
Modifier and Type | Class and Description |
---|---|
static class |
CategoricalDistribution.PMF
PMF of the Categorical Distribution
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NUM_CLASSES
Default number of classes (labels or parameters), 2.
|
protected Vector |
parameters
Parameters of the multinomial distribution, must be at least
2-dimensional and each element must be nonnegative.
|
Constructor and Description |
---|
CategoricalDistribution()
Creates a new instance of CategoricalDistribution
|
CategoricalDistribution(CategoricalDistribution other)
Copy constructor
|
CategoricalDistribution(int numClasses)
Creates a new instance of CategoricalDistribution
|
CategoricalDistribution(Vector parameters)
Creates a new instance of CategoricalDistribution
|
Modifier and Type | Method and Description |
---|---|
CategoricalDistribution |
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.
|
java.util.Set<Vector> |
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.
|
int |
getInputDimensionality()
Gets the dimensionality of the input vectors
|
Vector |
getMean()
Gets the arithmetic mean, or "first central moment" or "expectation",
of the distribution.
|
Vector |
getParameters()
Getter for parameters
|
CategoricalDistribution.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 |
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
protected Vector parameters
public CategoricalDistribution()
public CategoricalDistribution(int numClasses)
numClasses
- Number of classes (labels or parameters) to use.public CategoricalDistribution(Vector parameters)
parameters
- Parameters of the multinomial distribution, must be at least
2-dimensional and each element must be nonnegative.public CategoricalDistribution(CategoricalDistribution other)
other
- CategoricalDistribution to copypublic CategoricalDistribution 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 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 Vector getMean()
DistributionWithMean
getMean
in interface DistributionWithMean<Vector>
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 getInputDimensionality()
public java.util.Set<Vector> getDomain()
DiscreteDistribution
getDomain
in interface DiscreteDistribution<Vector>
public int getDomainSize()
DiscreteDistribution
getDomainSize
in interface DiscreteDistribution<Vector>
public CategoricalDistribution.PMF getProbabilityFunction()
ComputableDistribution
getProbabilityFunction
in interface ComputableDistribution<Vector>
getProbabilityFunction
in interface DiscreteDistribution<Vector>