Skip to content

Instantly share code, notes, and snippets.

@wfaria
Last active March 10, 2019 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wfaria/e63bfbc951e265eef2e5b402ffc94204 to your computer and use it in GitHub Desktop.
Save wfaria/e63bfbc951e265eef2e5b402ffc94204 to your computer and use it in GitHub Desktop.
Election Poll Simulation - Asking opinion from a single person.
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