Created
March 27, 2013 20:30
-
-
Save Newky/5257739 to your computer and use it in GitHub Desktop.
Probability rolls for gav guidance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gavodel