A code I borrowed from Yee Whye Teh on decimated Dirichlet distributions.