Skip to content

Instantly share code, notes, and snippets.

@zachaysan
Created November 22, 2013 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachaysan/7603526 to your computer and use it in GitHub Desktop.
Save zachaysan/7603526 to your computer and use it in GitHub Desktop.
Buffers Tools Python Help
import random
def flip(n):
on_tails = -1000 * 1000
if n == 0:
return 1
elif random.random() < 0.5:
return on_tails
else:
previous_flip = flip(n-1)
if previous_flip == on_tails:
return on_tails
else:
return 2 * previous_flip
results = {}
for i in range(1,100):
j_results = []
for j in range(1000):
j_results.append(flip(i))
results[i] = sum(j_results) / float(len(j_results))
from pprint import pprint
pprint(results)
{1: -479998.96,
2: -730998.924,
3: -866998.936,
4: -926998.832,
5: -976999.264,
6: -982998.912,
7: -992999.104,
8: -995998.976,
9: -998999.488,
10: -1000000.0,
11: -998997.952,
12: -1000000.0,
13: -1000000.0,
14: -998983.616,
15: -1000000.0,
16: -998934.464,
17: -1000000.0,
18: -1000000.0,
19: -1000000.0,
20: -1000000.0,
21: -1000000.0,
22: -1000000.0,
23: -1000000.0,
24: -1000000.0,
25: -1000000.0,
26: -1000000.0,
27: -1000000.0,
28: -1000000.0,
29: -1000000.0,
30: -1000000.0,
31: -1000000.0,
32: -1000000.0,
33: -1000000.0,
34: -1000000.0,
35: -1000000.0,
36: -1000000.0,
37: -1000000.0,
38: -1000000.0,
39: -1000000.0,
40: -1000000.0,
41: -1000000.0,
42: -1000000.0,
43: -1000000.0,
44: -1000000.0,
45: -1000000.0,
46: -1000000.0,
47: -1000000.0,
48: -1000000.0,
49: -1000000.0,
50: -1000000.0,
51: -1000000.0,
52: -1000000.0,
53: -1000000.0,
54: -1000000.0,
55: -1000000.0,
56: -1000000.0,
57: -1000000.0,
58: -1000000.0,
59: -1000000.0,
60: -1000000.0,
61: -1000000.0,
62: -1000000.0,
63: -1000000.0,
64: -1000000.0,
65: -1000000.0,
66: -1000000.0,
67: -1000000.0,
68: -1000000.0,
69: -1000000.0,
70: -1000000.0,
71: -1000000.0,
72: -1000000.0,
73: -1000000.0,
74: -1000000.0,
75: -1000000.0,
76: -1000000.0,
77: -1000000.0,
78: -1000000.0,
79: -1000000.0,
80: -1000000.0,
81: -1000000.0,
82: -1000000.0,
83: -1000000.0,
84: -1000000.0,
85: -1000000.0,
86: -1000000.0,
87: -1000000.0,
88: -1000000.0,
89: -1000000.0,
90: -1000000.0,
91: -1000000.0,
92: -1000000.0,
93: -1000000.0,
94: -1000000.0,
95: -1000000.0,
96: -1000000.0,
97: -1000000.0,
98: -1000000.0,
99: -1000000.0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment