Created
May 25, 2019 07:25
-
-
Save eLtronicsVilla/5a5ad50d174d5791bee741e22e35ed9b 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
import random | |
def bernoulli_trial(p): | |
return 1 if random.random() < p else 0 | |
def binomial(n,p): | |
return sum(bernoulli_trial(p) for _ in range(n)) | |
# Suppose this problem, there are 9 people selected (n = number of trials = 9). The probability of success is 0.62. | |
print(binomial(9,0.62)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment