Stixbox rgamma Bug II
After wasting an absurd amount of time trying to figure out where the bug in my code was for fitting Dirichlet parameters, it turns out that the bug actually wasn’t in my code, but was in my test data. It appears that Stixbox has a bug in its gamma random variate generator, rgamma that causes it to return 1 every once in a while, even if the parameter is very much larger than 1. Check out this histogram of 10,000 single-samples from rgamma(100):

The key thing to notice is all the samples at 1, way over to the left. Note that you don’t get this if you ask rgamma for all of the samples at once. It happens when you ask it for 10,000 samples one at a time, in code such as this:
gammas = [];
for i=1:10000
gammas = cat(1, rgamma(1, 100), gammas)
end
hist(gammas, 1000)