Skip to main content
3 of 4
edited tags

Sampling a Dirichlet Distribution efficiently

I'm sampling a DirichletDistribution like so:

n = 5000;
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?

Lokdal
  • 405
  • 2
  • 8