Created
March 28, 2021 07:47
-
-
Save grahamharrison68/0f90421ac2896ffcdd258dd95dcc7051 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
def normal_distribution_ci(confidence, x_bar, sigma, n): | |
z_score = stats.norm.interval(confidence)[1] | |
sigma_over_root_n = sigma / np.sqrt(n) | |
ci = [x_bar - z_score * sigma_over_root_n, x_bar + z_score * sigma_over_root_n] | |
return ci | |
def binomial_distribution_ci(confidence, p_hat, n): | |
z_score = stats.norm.interval(confidence)[1] | |
rhs = z_score * np.sqrt(p_hat*(1-p_hat))/n | |
ci = [p_hat - rhs, p_hat + rhs] | |
return ci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment