Created
December 10, 2019 06:03
-
-
Save joonro/f161c00d9fd78a57768f4e571edeac5f to your computer and use it in GitHub Desktop.
[Probability of randomly choose r correct answers out of n total questions] #python #teaching
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 math | |
n = 33 # number of questions | |
r = 6 # number of correct answers | |
probs = [] | |
for r in range(n): | |
prob_specific_case = ((1/5)** r * (4/5)** (n-r)) | |
num_comb = math.factorial(n) / (math.factorial(r) * math.factorial(n-r)) * prob_each_case | |
prob_case = num_comb * prob_specific_case | |
probs.append(prob) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment