Operators and Keywords

C++ API

Function File: y = mnpdf (x, p)

Compute the probability density function of the multinomial distribution.

#### Arguments

• x is vector with a single sample of a multinomial distribution with parameter p or a matrix of random samples from multinomial distributions. In the latter case, each row of x is a sample from a multinomial distribution with the corresponding row of p being its parameter.
• p is a vector with the probabilities of the categories or a matrix with each row containing the probabilities of a multinomial sample.

#### Return values

• y is a vector of probabilites of the random samples x from the multinomial distribution with corresponding parameter p. The parameter n of the multinomial distribution is the sum of the elements of each row of x. The length of y is the number of columns of x. If a row of p does not sum to `1`, then the corresponding element of y will be `NaN`.

#### Examples

```          x = [1, 4, 2];
p = [0.2, 0.5, 0.3];
y = mnpdf (x, p);

x = [1, 4, 2; 1, 0, 9];
p = [0.2, 0.5, 0.3; 0.1, 0.1, 0.8];
y = mnpdf (x, p);
```

#### References

1. Wendy L. Martinez and Angel R. Martinez. Computational Statistics Handbook with MATLAB. Appendix E, pages 547-557, Chapman & Hall/CRC, 2001.
2. Merran Evans, Nicholas Hastings and Brian Peacock. Statistical Distributions. pages 134-136, Wiley, New York, third edition, 2000.

Package: statistics