5 kyu

Probabilities for Sums in Rolling Cubic Dice

1,818 of 2,648raulbc777

Description:

When we throw 2 classical dice (values on each side from 1 to 6) we have 36 (6 * 6) different results.

We want to know the probability of having the sum of the results equals to 11. For that result we have only the combination of 6 and 5. So we will have two events: {5, 6} and {6, 5}

So the probability for that result will be:

P(11, 2) = 2/(6*6) = 1/18    (The two is because we have 2 dice)

Now, we want to calculate the probability of having the sum equals to 8. The combinations for that result will be the following: {4,4}, {3,5}, {5,3}, {2,6}, {6,2} with a total of five combinations.

P(8, 2) = 5/36 

Things may be more complicated if we have more dices and sum values higher.

We want to know the probability of having the sum equals to 8 but having 3 dice.

Now the combinations and corresponding events are:

{2,3,3}, {3,2,3}, {3,3,2}
{2,2,4}, {2,4,2}, {4,2,2}
{1,3,4}, {1,4,3}, {3,1,4}, {4,1,3}, {3,4,1}, {4,3,1}
{1,2,5}, {1,5,2}, {2,1,5}, {5,1,2}, {2,5,1}, {5,2,1}
{1,1,6}, {1,6,1}, {6,1,1}

A total amount of 21 different combinations

So the probability is:
P(8, 3) = 21/(6*6*6) = 0.09722222222222222

Summarizing the cases we have seen with a function that receives the two arguments

rolldice_sum_prob(11, 2) == 0.0555555555 # or 1/18

rolldice_sum_prob(8, 2) ==  0.13888888889# or 5/36

rolldice_sum_prob(8, 3) == 0.0972222222222  # or 7/72
>>> rolldiceSumProb 11 2
0.0555555555     -- or 1/18
>>> rolldiceSumProb 8 2
0.13888888889    -- or 5/36
>>> rolldiceSumProb 8 3
0.0972222222222  -- or 7/72

And think why we have this result:

rolldice_sum_prob(22, 3) == 0
>>> rolldiceSumProb 22 3
0

Create the function rolldice_sum_prob/rolldiceSumProb for this calculation.

Have a nice time!

(You do not have to round the results)

Mathematics
Statistics
Probability
Logic

Stats:

CreatedMar 27, 2016
PublishedMar 27, 2016
Warriors Trained7867
Total Skips1592
Total Code Submissions12056
Total Times Completed2648
Python Completions1818
Ruby Completions153
JavaScript Completions409
Rust Completions204
R Completions88
COBOL Completions4
Go Completions21
D Completions4
Julia Completions14
Haskell Completions4
Total Stars265
% of votes with a positive feedback rating94% of 401
Total "Very Satisfied" Votes359
Total "Somewhat Satisfied" Votes35
Total "Not Satisfied" Votes7
Total Rank Assessments10
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • raulbc777 Avatar
  • kazk Avatar
  • pavloslav Avatar
  • Voile Avatar
  • mentalplex Avatar
  • akar-0 Avatar
  • depial Avatar
  • tobeannouncd Avatar
Ad