You are viewing a single comment's thread. Return to all comments →
from fractions import Fraction from math import prod def probabilities(x, y, z): r1,r2 = Fraction(x[0], sum(x)),Fraction(y[0], sum(y)) b1,b2 = Fraction(x[1], sum(x)),Fraction(y[1], sum(y)) r3,b3 = Fraction(z[0], sum(z)),Fraction(z[1], sum(z)) return [(r1,r2,b3),(r1,b2,r3),(b1,r2,r3)] def calc_prob(x, y, z): to_mult = probabilities(x, y, z) prob = Fraction(0,1) for m in to_mult:prob += prod(m) return prob x,y,z= (4, 3),(5, 4),(4, 4) probability = calc_prob(x, y, z) print(f"{probability.numerator}/{probability.denominator}")
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 →