Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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$.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.