in spotify_confidence/analysis/frequentist/confidence_computers/z_test_computer.py [0:0]
def _compute_ci_for_row(row: Series) -> Tuple[float, float]:
if row[IS_SIGNIFICANT] and num_significant == m_scal:
alpha_adj = adjusted_alpha_rej_equal_m
elif row[IS_SIGNIFICANT] and num_significant < m_scal:
alpha_adj = adjusted_alpha_rej_less_m
else:
alpha_adj = adjusted_alpha_accept
ci_sign = -1 if row[PREFERENCE_TEST] == "larger" else 1
bound1 = row[DIFFERENCE] + ci_sign * st.norm.ppf(alpha_adj) * row[STD_ERR]
if ci_sign == -1:
bound2 = max(row[NULL_HYPOTHESIS], bound1)
else:
bound2 = min(row[NULL_HYPOTHESIS], bound1)
bound = bound2 if row[IS_SIGNIFICANT] else bound1
lower = bound if row[PREFERENCE_TEST] == "larger" else -np.inf
upper = bound if row[PREFERENCE_TEST] == "smaller" else np.inf
row[ADJUSTED_LOWER] = lower
row[ADJUSTED_UPPER] = upper
return row