-
Notifications
You must be signed in to change notification settings - Fork 0
/
theta_hat.py
38 lines (28 loc) · 988 Bytes
/
theta_hat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from Question import question_list
from expected_value import expected_value
from variance import variance
from fisher_information import fisher_information
from statistics import NormalDist
from math import sqrt
from thetas import thetas
def calculate_expected_value_and_variance(theta: float) -> float:
exp = theta
total_fisher_info = 0.0
for question in question_list:
total_fisher_info += fisher_information(question, theta)
var = 1 / total_fisher_info
return exp, var
theta_0A = 0
theta_0B = 2
exp = 0.0
var = 0.0
exp, var = calculate_expected_value_and_variance(theta_0A)
l_A = exp + (-1.645 * sqrt(var))
exp, var = calculate_expected_value_and_variance(theta_0B)
l_B = exp + (-1.645 * sqrt(var))
prob_A = list()
prob_B = list()
for theta in thetas:
exp, var = calculate_expected_value_and_variance(theta)
prob_A.append(NormalDist(0, 1).cdf((l_A - exp) / sqrt(var)))
prob_B.append(NormalDist(0, 1).cdf((l_B - exp) / sqrt(var)))