Skip to content

Instantly share code, notes, and snippets.

@tuxdna
Last active February 13, 2018 21:34
Show Gist options
  • Save tuxdna/c716dbc6965c5664ee2243d78a77f94d to your computer and use it in GitHub Desktop.
Save tuxdna/c716dbc6965c5664ee2243d78a77f94d to your computer and use it in GitHub Desktop.
Probability problem

Given a 6 sided dice, how many number of throws are required to guarantee a 6 as output?

This solution is basically finding expectation over 1 roll, 2 rolls, 3 rolls ... and so on until infinite rolls of dice. Basically SUM( k * P(rolls=k)) for k = 1 to infinity. Now probability we get a 6 in exactly kth roll is defined as P(rolls=k) = q^(k-1) * p, where p is probability we get a 6 in kth roll, and q^(k-1) is probability we do not get a 6 in all k-1 rolls. I guess it still cannot guarantee that we will always get a 6, rather that if we roll on average of 6 times in a row, we will get definitely get a 6. Quite interesting problem indeed.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment