Skip to content

Instantly share code, notes, and snippets.

@Newky
Created March 27, 2013 20:30
Show Gist options
  • Save Newky/5257739 to your computer and use it in GitHub Desktop.
Save Newky/5257739 to your computer and use it in GitHub Desktop.
Probability rolls for gav guidance
import random
def roll_dice():
return random.randint(1, 6)
def sum_two_dice():
sum_one = roll_dice()
sum_two = roll_dice()
return sum_one + sum_two
def act_prob(act_freq, M):
return float(act_freq) / M
def main(M):
result = []
# init the array
for i in range(2, 13):
result.append(0)
for i in range(0, M):
dice_sum = sum_two_dice()
result[dice_sum-2] += 1
for i in range(0, len(result)):
print "%d) %d %f" % (i+2, result[i], act_prob(result[i], M))
@Newky
Copy link
Author

Newky commented Mar 27, 2013

@gavodel

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