Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from scipy.stats import pearsonr
X = (4, 6, 1, 1, 0, 2, 5, 4, 0, 0)
Y = (201, 165, 145, 150, 160, 113, 140, 147, 83, 108)
Z = (15, 30, 28, 41, 18, 5, 7, 16, 15, 16)
print("Correlation between X and Y:", pearsonr(X, Y))
# Correlation between X and Y and p-value: (0.5258752464261707, 0.1184620607638331)
print("Correlation between Y and Z:", pearsonr(Y, Z))
# Correlation between Y and Z and p-value: (0.2926140030545373, 0.4119553089272353)
print("Correlation between X and Z:", pearsonr(X, Z))
# Correlation between X and Z and p-value: (-0.09559638117556471, 0.7927835119206453)
from scipy.stats import t
from scipy.stats import norm
survival_tdist = 1 - t.cdf(197, 2)
survival_normal = 1 - norm.cdf(6.0625)
# - the "6.0625" is a z-score where x = 197, x-bar = 100 and s = 16
def bayesian(N, E_n, E_t):
# N = Prob(IQ ~ N), E_n = Prob(IQ ~ N | O'Brien IQ), E_t = Prob(not IQ ~ N | O'Brien IQ)
P_nG = 1 - N
return (N * E_n) / ( (P_nG * E_t) + (N * E_n) )
priors = [.5, .75, .999, .9999, .99999, .999999, 1]
for k in priors:
print("P(N) =", k, "\t\tP(N|E) =", bayesian(k, survival_normal, survival_tdist) * 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment