[OT] Generating distribution of N dice rolls

H. S. Teoh hsteoh at qfbox.info
Thu Nov 10 16:57:59 UTC 2022


On Thu, Nov 10, 2022 at 11:45:50AM +0100, Timon Gehr via Digitalmars-d wrote:
[...]
> The distribution of the output is multinomial(n,k,[1/k,1/k,...,1/k]),
> i.e., n trials, k events, and the events follow an uniform
> distribution.  https://en.wikipedia.org/wiki/Multinomial_distribution

I have to admit, the linked article is way above my head.  I just don't
grok probability. :-(


> It is at least as hard to sample as binomial(n,1/k), because that is
> the marginal distribution of each component of the result.
[...]

Hmm.  I'm thinking one way to approximate this, if there's a fast way to
compute the standard deviation of the multinomial, is to use the
Box-Muller transform to do the initial population of the result array,
then distribute the remaining (N - sum(array)) elements by running
individual trials and adjusting the array accordingly.  The initial
population should bring us reasonably close to the mean, so (N -
sum(array)) should be small enough that running individual trials won't
be excessively expensive.

Or if (N - sum(array)) is still large, maybe do another estimate using
the standard deviation of the remaining trials to reduce it, and then
run the remaining trials manually?


T

-- 
Doubt is a self-fulfilling prophecy.


More information about the Digitalmars-d mailing list