Created
March 10, 2019 00:50
-
-
Save wfaria/2c6956cbe971913199c4a89bdeb2afaa to your computer and use it in GitHub Desktop.
Election Poll - margin of error method
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 get_margin_of_error_interval(sample_size, number_of_std_dvt): | |
day_sample = get_n_samples_from_distribution( | |
samples_number = 1, | |
sample_size = sample_size) | |
sample_mean = np.mean(day_sample) | |
sample_std_dvt = np.std(day_sample) | |
estimated_std_dvt = sample_std_dvt / math.sqrt(sample_size) | |
margin_of_error = number_of_std_dvt * estimated_std_dvt | |
return { "error": margin_of_error, "mean": sample_mean } | |
get_margin_of_error_interval(100, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment