Created
July 9, 2020 08:09
-
-
Save arimitramaiti/f757b7f84fac2611e80024b56e3bf08a to your computer and use it in GitHub Desktop.
An example to share population proportion estimation
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
##import required modules | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
sample_size = 40 #known from the sample collected by the manager | |
sample_success = 25 #known from the sample collected by the manager | |
proportion = sample_success/sample_size #sample proportion who rated more 6 or more | |
point_estmate = proportion #similar to proportion of the sample | |
standard_error = np.sqrt((proportion * (1-proportion))/sample_size) #formula is slightly different relative to population mean estimation | |
upper_limit = round(point_estmate + (stats.norm.ppf(0.975) * standard_error),3) #upper side of the interval | |
lower_limit = round(point_estmate - (stats.norm.ppf(0.975) * standard_error),3) #lower side of the interval | |
print("We are 95% confident that proportion of customers who rated the sandwich 6 & above lies between {}. and {}.".format(lower_limit, upper_limit)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment