• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# wonder

a guest Dec 29th, 2011 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #!/usr/bin/python2
2. #Filename : wonder.py
3.
4. from __future__ import division
5.
6.
7. round1_win_probability = 2/3
8. round2_win_probability = 0.5
9. round3_win_probability = 1/3
10. round4_win_probability = 1/4
11.
12. number_of_wins_round1 = 10
13. number_of_wins_round2 = 10
14. number_of_wins_round3 = 10
15. number_of_wins_round4 = 10
16.
17.
18.
19.
20. w1 = round1_win_probability
21. w2 = round2_win_probability
22. w3 = round3_win_probability
23. w4 = round4_win_probability
24. n1 = number_of_wins_round1
25. n2 = number_of_wins_round2
26. n3 = number_of_wins_round3
27. n4 = number_of_wins_round4
28. l1 = 1-w1
29. l2 = 1-w2
30. l3 = 1-w3
31. l4 = 1-w4
32.
33. wn1 = w1**n1
34. wn2 = w2**n2
35. wn3 = w3**n3
36. wn4 = w4**n4
37.
38. b=1
39. b1=1
40.
41. def wonderco(x,y,z,q):
42.   i = 1.0
43.   e = []
44.   nume = x
45.   denom = 1.0
46.   g = 1
47.
48.   while i <= x:
49.     e.append(round(g,0))
50.     g *= nume/denom
51.     nume += 1
52.     denom += 1
53.     i += 1
54.   e.reverse()
55.
56.   i = 0.0
57.   pr = 0
58.   while i < x:
59.     pr+=(y**i)*e.pop()
60.     i += 1
61.   ooo = pr*z
62.   print q, "%.7f" % ooo
63.   global b
64.   b *=pr*z
65.   global b1
66.   b1 = round(1/b)
67.
68. wonderco(n1,l1,wn1,"Round1:        ")
69. wonderco(n2,l2,wn2,"Round2:        ")
70. wonderco(n3,l3,wn3,"Round3:        ")
71. wonderco(n4,l4,wn4,"Round4:        ")
72. print "Overall prob.: ", "%.7f" % b, "    1 in ", b1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top