I play a lot of tabletop role-playing games, and I have been interested recently in modeling the various game mechanics involving dice.
As I see it, a single throw of an eight-sided die can be modeled trivially:
d = DiscreteUniformDistribution[{1, 8}]
However, what I'm more often modeling is something like a 4d8, i.e. the throw of four eight-sided dice. If the dice were continuous, this could be modeled as UniformSumDistribution[4, {1, 8}]
, but of course they are not, and there is no built-in DiscreteUniformSumDistribution
.
Instead, I can use a TransformedDistribution
:
d = TransformedDistribution[
x1 + x2 + x3 + x4,
Thread@Distributed[
{x1, x2, x3, x4},
DiscreteUniformDistribution[{1, 8}]]]
This works, but it's rather slow, especially when the number of dice is large. Are there better existing methods to model such dice throws in Mathematica that I'm not aware of?