You can calculate the probability mass function (pmf) or probability density function (pdf) of a multinomial distribution in MATLAB using the mnpdf function.
The syntax of the function is as follows:
main.m20 chars2 lines
where X is a matrix whose rows represent the observed values of the multinomial random variable, and pvals is a vector of length k containing the probabilities of the k possible outcomes of the multinomial distribution.
Here's an example code that calculates the probabilities of a multinomial distribution with k = 3 possible outcomes, given n = 10 trials and the following probabilities: p1 = 0.2, p2 = 0.5, and p3 = 0.3.
main.m183 chars9 lines
In this example, the X matrix has three rows, representing three different observations, each with three columns (one for each possible outcome). The n parameter is set to 10 for all observations. The resulting p vector contains the pmf values for each observation.
gistlibby LogSnag