Created
February 1, 2019 14:39
-
-
Save petrushev/d0466c7c700fb416895e5fd0898ad484 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from scipy import stats | |
import numpy as np | |
def interval_zscore(alpha=0.95): | |
""" | |
Return a zscore corresponding with a confidence interval | |
(e.g., for alpha=0.95, returns 1.96) | |
:param: alpha: float, the width of the confidence interval, default is 0.95 | |
""" | |
return stats.norm.ppf(1 - (1 - alpha) * 0.5) | |
def quotient_se(mean_a, mean_b, std_a, std_b, n_a, n_b): | |
"""Returns the standard error of the ratio of two means | |
""" | |
sem_a = std_a / np.sqrt(n_a) | |
sem_b = std_b / np.sqrt(n_b) | |
q = mean_a / mean_b | |
std_err_q = q * np.sqrt( | |
((sem_a**2)/(mean_a**2))+((sem_b**2)/(mean_b**2)) | |
) | |
return std_err_q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment