Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def sample_odds_path(p, s=0.05, N=2000):
- x = []
- xc = np.log(p) - np.log(1-p)
- for k in range(N):
- x.append(xc)
- f = np.exp(xc)
- xc += np.random.normal(loc=0, scale=s) + s**2 * (f-1)/(f+1)
- x = np.array(x)
- L = 1 - 1/(np.exp(x) + 1)
- return x, L
- mean_scores = []
- log_scores = []
- for _ in range(1000):
- x, L = sample_odds_path(0.5, s = 0.15, N = 500)
- q = np.random.choice(L, size=10)
- indicator = np.random.choice([0, 1], p=[1 - L[-1], L[-1]])
- mean_forecast = np.mean(q)
- mean_log_odds = 1 - 1/(np.exp(np.mean(np.log(q/(1-q)))) + 1)
- mean_scores.append(np.log(mean_forecast) if indicator == 1 else np.log(1 - mean_forecast))
- log_scores.append(np.log(mean_log_odds) if indicator == 1 else np.log(1 - mean_log_odds))
- print(np.mean(mean_scores), np.mean(log_scores))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement