Skip to content

Instantly share code, notes, and snippets.

@g-leech

g-leech/spock.py Secret

Created Jun 4, 2021
Embed
What would you like to do?
Comparing Spock's predictions to a coin flip
import numpy as np
# impossible 0
# v unlik 10
# unlik 25
# lik 75
# vv likely 99.5
preds = [
[0, 1],
[0.75, 1],
[0.75, 0],
[0, 1],
[0, 0],
[0, 1],
[0, 1],
[0, 1],
[0.995, 1],
[0.995, 0],
[0.995, 0],
[0.25, 1],
[0.1, 1],
[0, 1],
[0.1, 0],
[0.1, 0],
[0.1, 0],
[0.995, 0],
[0.995, 0],
[0.81, 1],
[0.75, 0],
[0.825, 1],
[0.75, 1],
[0, 1],
]
def brier(ps):
ses = [(p[0] - p[1])**2 for p in ps]
return np.mean(ses)
print(brier(preds))
def flip() :
return np.random.randint(0, 2)
cs = []
for i in range(10000):
coin = [[flip(), p[1]] for p in preds]
cs.append(brier(coin))
print(np.mean(cs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment