There is an algorithm to generate Dirichlet samples using a sampler for Gamma distribution for any and . We will generate Gamma distributed variables , for , and do the following variable transformation to get Dirichlet samples . First we should demonstrate that this transformation results in Dirichlet distributed samples.
Consider the following tranformation , where and . We can rewrite this transformation as , where and . Also we can imediatly calculate the inverse transformation , with . From the transformation definition we know that , implying that and .
Now we can apply the formula for transformation of variables to , and (using the notation that is the pdf of the random variables and is the pdf of the random variables ):
So we need to compute the determinant of the Jacobian of the transformation.
Computing the individual terms, for and ,
In matricial forms we have:
Now with this result from the determinant of the Jacobian, we will apply it in the transformation of random variables formula for the pdf and marginilize to get the pdf of .
This finish our demonstration that the given transformation of Gamma distributed random variables results in Dirichlet distributed random variables. Notice that is totally determined by (), so we can actually express the right side of the equation as a formula of only .
If drawing samples from a Gamma distribution can be performed with complexity , than samples from a Dirichlet distribution can be computed with the same complexity.