Post Reply 
Sum of roll of N dice
05-02-2018, 06:21 AM (This post was last modified: 05-02-2018 06:33 AM by pier4r.)
Post: #3
RE: Sum of roll of N dice
Throwing some quick ideas.

A sort of montecarlo method?

If one has N dice, one knows the theoretical distribution for all the results between N and 6*N.

Therefore one can just work with it. The main idea is to roll one large dice to simulate the result of a series of smaller dice.

Ex:
N = 3
Smallest probability { 1 1 1 } (or { 6 6 6 } ) -> 1/216

Pick a uniform integer number between 1 and 216 and assign results accordingly.
For example if 1 -> { 1 1 1 }
the range 2-4 is for the combinations of { 1 1 2 } (the order doesn't matter)
the range 5-7 is for the combinations of { 1 1 3 }
...
the range 216-216 is for { 6 6 6 }

If the order matters, like below, then every combination has weight 1.

Note that if one doesn't want to keep a table: "range - combination", one has to compute it on the fly given a number between 1 and 216, to identify the right combination. The combination is increasing, a bit like a number in base 7 excluding zeroes. so
{1 1 1}
{1 1 2}
{1 1 3}
...
{2 4 4}
{2 4 5}
...
{5 5 5}
{5 5 6}
...
{6 6 5}
{6 6 6}
And each combination has a known weight ( equal to 1, as one is going to check all of them, for example { 1 1 2 } as well as { 2 1 1} or { 1 2 1 } ) so one can compute the different ranges increasingly.
Then one, knowing the combination chosen by the number between 1 and 216, can sum its digits. Returning the result with proper probability.

The same can be done to, instead of matching the combinations, matching directly the sum of the digits, that maybe saves space.
I am pretty sure that one can simplify the computation even more.

side observation.
The HP calculator group on Facebook is now quite active. It is a pity that it has interesting questions that are difficult to reach again by Facebook's design. Facebook is focused on the last posts, while old posts get increasingly hard to reach due to the infinite scrolling. Damn the designers that keeps using infinite scrolling.

edit.
(05-02-2018 05:48 AM)Gerald H Wrote:  should this unlikely event occur I will acknowledge the superiority of my antagonists' reasoning.

Now I demand, given my superior argument, that you post even more programming challenges and guardian puzzles! HA!

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sum of roll of N dice - Joe Horn - 05-02-2018, 05:06 AM
RE: Sum of roll of N dice - Gerald H - 05-02-2018, 05:48 AM
RE: Sum of roll of N dice - pier4r - 05-02-2018 06:21 AM
RE: Sum of roll of N dice - Jim Horn - 05-02-2018, 07:01 AM
RE: Sum of roll of N dice - pier4r - 05-02-2018, 08:04 AM
RE: Sum of roll of N dice - John Keith - 05-02-2018, 02:07 PM
RE: Sum of roll of N dice - Jim Horn - 05-02-2018, 05:58 PM
RE: Sum of roll of N dice - John Keith - 05-02-2018, 07:18 PM
RE: Sum of roll of N dice - Gerald H - 05-02-2018, 08:01 AM
RE: Sum of roll of N dice - Werner - 05-03-2018, 12:39 PM
RE: Sum of roll of N dice - Gerald H - 05-03-2018, 04:49 PM
RE: Sum of roll of N dice - Werner - 05-03-2018, 05:14 PM
RE: Sum of roll of N dice - Gamo - 05-02-2018, 10:54 AM
RE: Sum of roll of N dice - Joe Horn - 05-02-2018, 12:03 PM
RE: Sum of roll of N dice - Joe Horn - 05-02-2018, 02:00 PM
RE: Sum of roll of N dice - John Keith - 05-02-2018, 07:15 PM
RE: Sum of roll of N dice - Dieter - 05-02-2018, 07:38 PM
RE: Sum of roll of N dice - pier4r - 05-02-2018, 07:44 PM
RE: Sum of roll of N dice - Jim Horn - 05-02-2018, 09:51 PM
RE: Sum of roll of N dice - Csaba Tizedes - 05-03-2018, 08:16 AM
RE: Sum of roll of N dice - SlideRule - 05-04-2018, 12:23 AM
RE: Sum of roll of N dice - Csaba Tizedes - 05-04-2018, 06:09 AM
RE: Sum of roll of N dice - Joe Horn - 05-04-2018, 07:32 AM
RE: Sum of roll of N dice - SlideRule - 05-03-2018, 01:55 PM
RE: Sum of roll of N dice - Gamo - 05-04-2018, 06:27 AM
RE: Sum of roll of N dice - Joe Horn - 05-04-2018, 07:12 AM
RE: Sum of roll of N dice - SlideRule - 05-04-2018, 11:30 AM
RE: Sum of roll of N dice - Michael Zinn - 05-04-2018, 06:35 PM
RE: Sum of roll of N dice - Dieter - 05-04-2018, 08:04 PM
RE: Sum of roll of N dice - Dieter - 05-05-2018, 06:38 PM
RE: Sum of roll of N dice - Dieter - 05-06-2018, 06:12 PM
RE: Sum of roll of N dice - zooropa1844 - 05-06-2018, 10:11 AM
RE: Sum of roll of N dice - zooropa1844 - 05-06-2018, 08:18 PM
RE: Sum of roll of N dice - Dieter - 05-06-2018, 09:02 PM
RE: Sum of roll of N dice - zooropa1844 - 05-06-2018, 09:31 PM
RE: Sum of roll of N dice - pier4r - 05-08-2018, 05:14 PM
RE: Sum of roll of N dice - Allen - 05-11-2018, 12:11 AM
RE: Sum of roll of N dice - Allen - 05-11-2018, 01:32 AM
RE: Sum of roll of N dice - zooropa1844 - 05-11-2018, 06:55 AM
RE: Sum of roll of N dice - brickviking - 05-11-2018, 09:52 AM
RE: Sum of roll of N dice - Allen - 05-11-2018, 12:19 PM
RE: Sum of roll of N dice - Thomas Klemm - 06-23-2018, 09:36 PM
RE: Sum of roll of N dice - rprosperi - 06-23-2018, 10:33 PM
RE: Sum of roll of N dice - ttw - 06-24-2018, 01:08 AM



User(s) browsing this thread: 3 Guest(s)