# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# prob.MultinomialDistribution class

Package: prob
Superclasses: prob.ParametricTruncatableDistribution

Multinomial probability distribution object

## Description

`prob.MultinomialDistribution` is an object consisting of parameters and a model description for a multinomial probability distribution. Create a probability distribution object with specified parameters using `makedist`.

## Construction

`pd = makedist('Multinomial')` creates a multinomial probability distribution object using the default parameter values.

`pd = makedist('Multinomial','Probabilities',probabilities)` creates a multinomial distribution object using the specified parameter value.

### Input Arguments

expand all

Outcome probabilities, specified as a vector of scalar values in the range `[0,1]`. Each vector element is the probability that a multinomial trial has a particular corresponding outcome. The values in `probabilities` must sum to 1.

Data Types: `single` | `double`

## Properties

expand all

Outcome probabilities for the multinomial distribution, stored as a vector of scalar values in the range `[0,1]`. The values in `probabilities` must sum to 1.

Data Types: `single` | `double`

Probability distribution name, stored as a character vector. This property is read-only.

Data Types: `char`

Logical flag for truncated distribution, stored as a logical value. If `IsTruncated` equals `0`, the distribution is not truncated. If `IsTruncated` equals `1`, the distribution is truncated. This property is read-only.

Data Types: `logical`

Number of parameters for the probability distribution, stored as a positive integer value. This property is read-only.

Data Types: `single` | `double`

Distribution parameter descriptions, stored as a cell array of character vectors. Each cell contains a short description of one distribution parameter. This property is read-only.

Data Types: `char`

Distribution parameter names, stored as a cell array of character vectors. This property is read-only.

Data Types: `char`

Distribution parameter values, stored as a vector. This property is read-only.

Data Types: `single` | `double`

Truncation interval for the probability distribution, stored as a vector containing the lower and upper truncation boundaries. This property is read-only.

Data Types: `single` | `double`

## Methods

### Inherited Methods

 cdf Cumulative distribution function of probability distribution object icdf Inverse cumulative distribution function of probability distribution object iqr Interquartile range of probability distribution object median Median of probability distribution object pdf Probability density function of probability distribution object random Generate random numbers from probability distribution object truncate Truncate probability distribution object
 mean Mean of probability distribution object std Standard deviation of probability distribution object var Variance of probability distribution object

## Definitions

### Multinomial Distribution

The multinomial distribution is a generalization of the binomial distribution. While the binomial distribution gives the probability of the number of "successes" in n independent trials of a two-outcome process, the multinomial distribution gives the probability of each combination of outcomes in n independent trials of a k-outcome process. The probability of each outcome in any one trial is given by the fixed probabilities p1, ..., pk.

The multinomial distribution uses the following parameters.

ParameterDescriptionSupport
`probabilities`Outcome probabilities$0\le probabilities\left(i\right)\le 1\text{\hspace{0.17em}};\text{\hspace{0.17em}}\sum _{all\left(i\right)}probabilities\left(i\right)=1$

The probability density function (pdf) is

`$f\left(x|n,p\right)=\frac{n!}{{x}_{1}!\dots {x}_{k}!}{p}_{1}{}^{{x}_{1}}\cdots {p}_{k}{}^{{x}_{k}}\text{ };\text{ }\sum _{1}^{k}{x}_{i}=n\text{\hspace{0.17em}},\text{\hspace{0.17em}}\sum _{1}^{k}{p}_{i}=1\text{\hspace{0.17em}},$`

where x = (x1,...,xk) gives the number of each k outcome in n trials of a process with fixed probabilities p = (p1,...,pk) of individual outcomes in any one trial.

## Examples

expand all

Create a multinomial distribution object using the default parameter values.

`pd = makedist('Multinomial')`
```pd = MultinomialDistribution Probabilities: 0.5000 0.5000```

Create a multinomial distribution object for a distribution with three possible outcomes. Outcome 1 has a probability of 1/2, outcome 2 has a probability of 1/3, and outcome 3 has a probability of 1/6.

`pd = makedist('Multinomial','probabilities',[1/2 1/3 1/6])`
```pd = MultinomialDistribution Probabilities: 0.5000 0.3333 0.1667```

Generate a random outcome from the distribution.

```rng('default'); % for reproducibility r = random(pd)```
```r = 2 ```

The result of this trial is outcome 2. By default, the number of trials in each experiment, n, equals 1.

Generate random outcomes from the distribution when the number of trials in each experiment, n, equals 1, and the experiment is repeated ten times.

```rng('default'); % for reproducibility r = random(pd,10,1)```
```r = 2 3 1 3 2 1 1 2 3 3```

Each element in the array is the outcome of an individual experiment that contains one trial.

Generate random outcomes from the distribution when the number of trials in each experiment, n, equals 5, and the experiment is repeated ten times.

```rng('default'); % for reproducibility r = random(pd,10,5)```
```r = 2 1 2 2 1 3 3 1 1 1 1 3 3 1 2 3 1 3 1 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 2 3 1 1 2 3 2 2 3 2 3 3 1 1 2```

Each element in the resulting matrix is the outcome of one trial. The columns correspond to the five trials in each experiment, and the rows correspond to the ten experiments. For example, in the first experiment (corresponding to the first row), 2 of the 5 trials resulted in outcome 1, and 3 of the 5 trials resulted in outcome 2.