including the Jacobian, one obtains: Each of the variables and likewise . Finally, integrate out the extra degree of freedom and one obtains: Which is equivalent to with support Below is example Python code to draw the sample: params = [a1, a2, ..., ak] sample = [random.gammavariate(a, 1) for a in params] sample = [v / sum(sample) for v in sample] This formulation is correct regardless of how the Gamma distributions are parameterized (shape/scale vs. shape/rate) because they are equivalent when scale and rate equal 1.0. From marginal beta distributions A less efficient algorithm relies on the univariate marginal and conditional distributions being beta and proceeds as follows. Simulate from Then simulate in order, as follows. For , simulate from and let Finally, set This iterative procedure corresponds closely to the "string cutting" intuition described above. Below is example Python code to draw the sample: params = [a1, a2, ..., ak] xs = [random.betavariate(params[0], sum(params[1:]))] for j in range(1, len(params) - 1): phi = random.betavariate(params[j], sum(params[j + 1 :])) xs.append((1 - sum(xs)) * phi) xs.append(1 - sum(xs)) See also Generalized Dirichlet distribution Grouped Dirichlet distribution Inverted Dirichlet distribution Latent Dirichlet allocation Dirichlet process Matrix variate Dirichlet distribution References External links Dirichlet Distribution How to estimate the parameters of the compound Dirichlet distribution (Pólya distribution) using expectation-maximization (EM) Dirichlet Random Measures, Method of Construction via Compound Poisson Random Variables, and Exchangeability Properties of the resulting Gamma Distribution SciencesPo: R package that contains functions for simulating parameters of the Dirichlet distribution. Multivariate continuous distributions Conjugate prior distributions Exponential family distributions Continuous distributions