Last active
March 10, 2019 01:35
-
-
Save wfaria/e63bfbc951e265eef2e5b402ffc94204 to your computer and use it in GitHub Desktop.
Election Poll Simulation - Asking opinion from a single person.
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 numpy as np | |
import matplotlib.pyplot as plt | |
import math | |
def get_opinion_from_random_person(): | |
# Usually this probabiliy is not known. Setting it here for simulation purposes. | |
probability_of_alice_win = 0.53 | |
return np.random.binomial( | |
n = 1, | |
p = probability_of_alice_win) | |
get_opinion_from_random_person() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment