I have a draw from a Dirichlet distribution that I would like to use as input into a MultinomialDistribution. For instance:
rand = RandomVariate[
DirichletDistribution[{1, 1, 1, 1, 1, 239, 302, 1}]]
Then I want to take this list and put it into a MultinomialDistribution and draw a sample from that. For instance:
RandomVariate[MultinomialDistribution[1, rand]]
It throws an error.
"The value \
{2.02597*10^-6,0.000659251,0.00210503,0.000496145,0.00063576,0.426032,\
0.564779} at position 2 in \
MultinomialDistribution[1,{2.02597*10^-6,0.000659251,0.00210503,0.\
000496145,0.00063576,0.426032,0.564779}] is expected to be a list of \
numbers greater than or equal to 0 and summing to 1. "
Probably because of:
Total[rand]
0.994709
My understanding is that the sum of the values drawn from a Dirichlet should equal one. However, in this case, they don't and I'm not sure why. Is this a mathematica issue or an issue with my understanding of the Dirichlet. I suspect the prior because I can do this in python (with numpy) okay and they always add to one. 0.99 is pretty close to 1. Is there perhaps a workaround for this?
I can reproduce this on an even smaller set:
bins = {1, 2, 3, 1, 10}
Total[RandomVariate[DirichletDistribution[bins]]]
Length[RandomVariate[DirichletDistribution[bins]]]
Returns:
0.443586
4