1
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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