Discuss Scratch

Sarevok390
Scratcher
53 posts

Dice Probability Calculator going wrong.

Hey all, my dice probability calculator is giving incorrect numbers. Its a calculator for scenarios such as you have 3 dice and 2 of them must roll sixes. Not sure why it's screwing up, might be an error of my part on the nCr or adding all the chances together. Like I said, not sure what's going wrong. https://scratch.mit.edu/projects/376742265/
PutneyCat
Scratcher
500+ posts

Dice Probability Calculator going wrong.

As far as I can tell on a quick look you've got the correct building blocks but haven't necessarily put them together correctly.

(1) There is an ambiguity in the question “How many dice are required to hit the target number?” Are you asking for the exact number or the minimum number?

(2) I don't understand why you seem to calculate odds based on what the target number is. The target number (i.e. whether you need to roll 6s or 5s or 1s or whatever) isn't going to change the odds. For six-sided dice, it's always 1/6 to roll a specific number, 5/6 to roll any of the other 5 numbers.

(3) The calculation bit of your scripts (“+calc”)seems unnecessarily complicated and is probably where things are going wrong. If e.g you want the odds of exactly two sixes out of three dice, the calculation is simply:

3 choose 2 x (1/6)^2 x (5/6)^1.

You seem to have all you need to work that out - your nCr does the 3 choose 2 bit, and your multiply number by itself bit does the rest.

If you want the odds of at least two sixes, you'd need to add on the odds of getting 3 sixes, which would be

3 choose 3 x (1/6)^3 x (5/6)^0.

Last edited by PutneyCat (March 18, 2020 14:29:49)

Sarevok390
Scratcher
53 posts

Dice Probability Calculator going wrong.

when putneycat answers
say [thanks] for (190000000000000000) secs
follow putneycat
PutneyCat
Scratcher
500+ posts

Dice Probability Calculator going wrong.

Powered by DjangoBB