Skip to content

Instantly share code, notes, and snippets.

@pdeperio
Last active August 6, 2018 17:29
Show Gist options
  • Save pdeperio/9a1fe95d29cd5fdad8310dd37ef07898 to your computer and use it in GitHub Desktop.
Save pdeperio/9a1fe95d29cd5fdad8310dd37ef07898 to your computer and use it in GitHub Desktop.
Naive p-value calculation
import numpy as np
poisson_mean = 7.56
poisson_sigma = 0.61
observation = 14
trials = int(1e7)
expectation = np.random.normal(poisson_mean, poisson_sigma, trials)
counts = np.random.poisson(expectation)
import matplotlib.pyplot as plt
plt.hist(counts, bins=100)
plt.show()
print(1.*len(counts[counts>=observation])/len(counts) )
# 0.0257866
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment