Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - #!/usr/bin/python2
 - #Filename : wonder.py
 - from __future__ import division
 - round1_win_probability = 2/3
 - round2_win_probability = 0.5
 - round3_win_probability = 1/3
 - round4_win_probability = 1/4
 - number_of_wins_round1 = 10
 - number_of_wins_round2 = 10
 - number_of_wins_round3 = 10
 - number_of_wins_round4 = 10
 - w1 = round1_win_probability
 - w2 = round2_win_probability
 - w3 = round3_win_probability
 - w4 = round4_win_probability
 - n1 = number_of_wins_round1
 - n2 = number_of_wins_round2
 - n3 = number_of_wins_round3
 - n4 = number_of_wins_round4
 - l1 = 1-w1
 - l2 = 1-w2
 - l3 = 1-w3
 - l4 = 1-w4
 - wn1 = w1**n1
 - wn2 = w2**n2
 - wn3 = w3**n3
 - wn4 = w4**n4
 - b=1
 - b1=1
 - def wonderco(x,y,z,q):
 - i = 1.0
 - e = []
 - nume = x
 - denom = 1.0
 - g = 1
 - while i <= x:
 - e.append(round(g,0))
 - g *= nume/denom
 - nume += 1
 - denom += 1
 - i += 1
 - e.reverse()
 - i = 0.0
 - pr = 0
 - while i < x:
 - pr+=(y**i)*e.pop()
 - i += 1
 - ooo = pr*z
 - print q, "%.7f" % ooo
 - global b
 - b *=pr*z
 - global b1
 - b1 = round(1/b)
 - wonderco(n1,l1,wn1,"Round1: ")
 - wonderco(n2,l2,wn2,"Round2: ")
 - wonderco(n3,l3,wn3,"Round3: ")
 - wonderco(n4,l4,wn4,"Round4: ")
 - print "Overall prob.: ", "%.7f" % b, " 1 in ", b1
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment