# How to plot multinomial beta from Dirichlet Distribution

I would like to plot the multinomial beta from the Dirichlet Distribution wiki page.

$$\mathrm{B}(\alpha) = \frac{\prod_{i=1}^K \Gamma(\alpha_i)}{\Gamma\bigl(\sum_{i=1}^K \alpha_i\bigr)},\qquad\alpha=(\alpha_1,\dots,\alpha_K)$$

Looking at the equation, the only input should be a vector of alphas of size $K$.

What Octave/Matlab function(s) should I use? I found the following Matlab beta function, but it seems to be only for $K=2$.

-

You can use the gamma and gammaln in MATLAB to directly compute the expression you have. I would recommend gammaln since you will have very big numbers, and the logarithmic form avoids computing the ratio of big numbers.
Also, if you want to sample from Dirichlet, you can generate bunch of gamma random variables using gamrnd (in statistics toolbox) and then normalize.