You are viewing a single comment's thread. Return to all comments →
import itertools from fractions import Fraction from collections import Counter
X = list(Counter({1:4, 0:3}).elements()) Y = list(Counter({1:5, 0:4}).elements()) Z = list(Counter({1:4, 0:4}).elements())
TOTAL_SAMPLES = list(itertools.product(X, Y, Z)) TOTAL_SAMPLES_SIZE = len(TOTAL_SAMPLES)
FAVOURABLE_OUTCOMES_SIZE = sum([sum(i) == 2 for i in list(itertools.product(X, Y, Z))])
print(Fraction(FAVOURABLE_OUTCOMES_SIZE,TOTAL_SAMPLES_SIZE))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Compound Event Probability
You are viewing a single comment's thread. Return to all comments →
import itertools from fractions import Fraction from collections import Counter
X = list(Counter({1:4, 0:3}).elements()) Y = list(Counter({1:5, 0:4}).elements()) Z = list(Counter({1:4, 0:4}).elements())
TOTAL_SAMPLES = list(itertools.product(X, Y, Z)) TOTAL_SAMPLES_SIZE = len(TOTAL_SAMPLES)
FAVOURABLE_OUTCOMES_SIZE = sum([sum(i) == 2 for i in list(itertools.product(X, Y, Z))])
Probability as a fraction
print(Fraction(FAVOURABLE_OUTCOMES_SIZE,TOTAL_SAMPLES_SIZE))