Skip to main content
1 of 4
Lokdal
  • 405
  • 2
  • 8

Sampling a Dirichlet Distribution efficiently

I'm sampling a DirichletDistribution like so:

n = 5 000;

par1 = Table[1./n,n];

data1 = RandomVariate[DirichletDistribution[par1],50]; (* This takes about 1.5 seconds *)

par2 = Table[1.,n];

data2 = RandomVariate[DirichletDistribution[par2],50]; (* This takes about 0.10 seconds *)

If I play with the value of the parameters, I find that giving values > 1 radically improves the performance.

Any clues on how to circumvent this? Thanks!

Lokdal
  • 405
  • 2
  • 8