[OT] Generating distribution of N dice rolls

jmh530 john.michael.hall at gmail.com
Thu Nov 10 11:59:11 UTC 2022


On Thursday, 10 November 2022 at 10:45:50 UTC, Timon Gehr wrote:
> [snip]
>
> 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
>
> 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.
>
> I guess one approach is this (if you can find a way to sample 
> from binomial distributions that is good enough for your use 
> case):
>
> [snip]

mir-random has the ability to sample from both the binomial [1] 
and multinomial [2] distributions (you would want the multinomial 
here, unless I'm missing something). I don't know how well 
mir-random handles large values of N or K, but there are also 
well-known normal and poisson approximations of the binomial 
distribution (I make some use of them here [3] for binomials) at 
least.

I wasn't exactly sure what you meant by the events follow a 
uniform distribution, but it's certainly possible to simulate 
from the multinomial to get the counts. You should also be able 
to calculate the PMF for it to compare the simulations against. 
The PMF shouldn't be uniform.


[1] 
http://mir-random.libmir.org/mir_random_variable.html#BinomialVariable
[2] 
http://mir-random.libmir.org/mir_random_ndvariable.html#MultinomialVariable
[3] 
https://github.com/libmir/mir-stat/blob/master/source/mir/stat/distribution/binomial.d


More information about the Digitalmars-d mailing list