Click or drag to resize
Accord.NET (logo)

MultinomialDistribution Class

Multinomial probability distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.MultivariateMultivariateDiscreteDistribution
      Accord.Statistics.Distributions.MultivariateMultinomialDistribution

Namespace:  Accord.Statistics.Distributions.Multivariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.5.0
Syntax
[SerializableAttribute]
public class MultinomialDistribution : MultivariateDiscreteDistribution, 
	IFittableDistribution<double[], IFittingOptions>, IFittable<double[], IFittingOptions>, 
	IFittable<double[]>, IFittableDistribution<double[]>, IDistribution<double[]>, 
	IDistribution, ICloneable
Request Example View Source

The MultinomialDistribution type exposes the following members.

Constructors
  NameDescription
Public methodMultinomialDistribution
Initializes a new instance of the MultinomialDistribution class.
Top
Properties
  NameDescription
Public propertyCovariance
Gets the variance-covariance matrix for this distribution.
(Overrides MultivariateDiscreteDistributionCovariance.)
Public propertyDimension
Gets the number of variables for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertyMean
Gets the mean for this distribution.
(Overrides MultivariateDiscreteDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertyMode
Gets the mode for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertyNumberOfTrials
Gets the number of Bernoulli trials N.
Public propertyProbabilities
Gets the event probabilities associated with the trials.
Public propertySupport
Gets the support interval for this distribution.
(Overrides MultivariateDiscreteDistributionSupport.)
Public propertyVariance
Gets the variance vector for this distribution.
(Overrides MultivariateDiscreteDistributionVariance.)
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)
Public methodComplementaryDistributionFunction
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point x. This function is also known as the Survival function.
(Inherited from MultivariateDiscreteDistribution.)
Public methodDistributionFunction
Not supported.
(Overrides MultivariateDiscreteDistributionDistributionFunction(Int32).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateDiscreteDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Double)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInverseDistributionFunction
Not supported.
(Inherited from MultivariateDiscreteDistribution.)
Public methodLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point x.
(Overrides MultivariateDiscreteDistributionLogProbabilityMassFunction(Int32).)
Public methodMarginalDistributionFunction(Int32)
Gets the marginal distribution of a given variable.
(Inherited from MultivariateDiscreteDistribution.)
Public methodMarginalDistributionFunction(Int32, Int32)
Gets the marginal distribution of a given variable evaluated at a given value.
(Inherited from MultivariateDiscreteDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Overrides MultivariateDiscreteDistributionProbabilityMassFunction(Int32).)
Public methodToString
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(IFormatProvider)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String, IFormatProvider)
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by Matrix.)
Top
Remarks

The multinomial distribution is a generalization of the binomial distribution. The binomial distribution is the probability distribution of the number of "successes" in n independent Bernoulli trials, with the same probability of "success" on each trial.

In a multinomial distribution, the analog of the Bernoulli distribution is the categorical distribution, where each trial results in exactly one of some fixed finite number k of possible outcomes, with probabilities p1, ..., pk and there are n independent trials.

References:

Examples
// distribution parameters
int numberOfTrials = 5; 
double[] probabilities = { 0.25, 0.75 };

// Create a new Multinomial distribution with 5 trials for 2 symbols
var dist = new MultinomialDistribution(numberOfTrials, probabilities);

int dimensions = dist.Dimension; // 2

double[] mean = dist.Mean;     // {  1.25, 3.75 }
double[] median = dist.Median; // {  1.25, 3.75 }
double[] var = dist.Variance;  // { -0.9375, -0.9375 }

double pdf1 = dist.ProbabilityMassFunction(new[] { 2, 3 }); // 0.26367187499999994
double pdf2 = dist.ProbabilityMassFunction(new[] { 1, 4 }); // 0.3955078125
double pdf3 = dist.ProbabilityMassFunction(new[] { 5, 0 }); // 0.0009765625
double lpdf = dist.LogProbabilityMassFunction(new[] { 1, 4 }); // -0.9275847384929139

// output is "Multinomial(x; n = 5, p = { 0.25, 0.75 })"
string str = dist.ToString(CultureInfo.InvariantCulture);
See Also