# Untitled

a guest
Nov 13th, 2021
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2.
3. def sample_odds_path(p, s=0.05, N=2000):
4.     x = []
5.     xc = np.log(p) - np.log(1-p)
6.
7.     for k in range(N):
8.         x.append(xc)
9.         f = np.exp(xc)
10.         xc += np.random.normal(loc=0, scale=s) + s**2 * (f-1)/(f+1)
11.
12.     x = np.array(x)
13.     L = 1 - 1/(np.exp(x) + 1)
14.
15.     return x, L
16.
17. mean_scores = []
18. log_scores = []
19.
20. for _ in range(1000):
21.     x, L = sample_odds_path(0.5, s = 0.15, N = 500)
22.     q = np.random.choice(L, size=10)
23.
24.     indicator = np.random.choice([0, 1], p=[1 - L[-1], L[-1]])
25.
26.     mean_forecast = np.mean(q)
27.     mean_log_odds = 1 - 1/(np.exp(np.mean(np.log(q/(1-q)))) + 1)
28.
29.     mean_scores.append(np.log(mean_forecast) if indicator == 1 else np.log(1 - mean_forecast))
30.     log_scores.append(np.log(mean_log_odds) if indicator == 1 else np.log(1 - mean_log_odds))
31.
32. print(np.mean(mean_scores), np.mean(log_scores))
RAW Paste Data