Created
October 1, 2020 18:24
-
-
Save gbushnell/67c99620f09019cb18c6a4624fe35664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate Confidence Intervals for probability matrix | |
def calc_confidence_interval(alpha): | |
alpha_stat = stats.norm.ppf(1 - (1 - alpha) / 2) | |
for d_i in range(expected_prob_matrix.shape[0]): | |
for n_i in range(expected_prob_matrix.shape[1]): | |
prop_exp = expected_prob_matrix[d_i, n_i] | |
half_length = alpha_stat * (prop_exp * (1 - prop_exp) / data_cols_length[n_i]) ** .5 + ( | |
1 / (2 * data_cols_length[n_i])) | |
u_bound = prop_exp + half_length | |
l_bound = prop_exp - half_length | |
h_length_matrix[d_i, n_i] = half_length | |
u_bound_matrix[d_i, n_i] = u_bound | |
l_bound_matrix[d_i, n_i] = max(l_bound, 0) | |
calc_confidence_interval(alpha_level) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment