We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Artificial Intelligence
- Probability & Statistics - Foundations
- Day 2: Basic Probability Puzzles #4
- Discussions
Day 2: Basic Probability Puzzles #4
Day 2: Basic Probability Puzzles #4
Sort by
recency
|
16 Discussions
|
Please Login in order to post a comment
I tried to do it both pythonically and with clear decipherability from the problem description. Pythonically meant, in this context, making good use of the unpacking operators.
from math import comb
total_ways = comb(9, 1) * comb(10, 2)
ways_case_A = comb(4, 1) * comb(7, 2)
ways_case_B = comb(5, 1) * comb(7, 1) * comb(3, 1)
successful_ways = ways_case_A + ways_case_B
from fractions import Fraction probability = Fraction(successful_ways, total_ways)
print(probability)
check out the link for full working code in python with explanation of where it's used in AI and ML, so probability is important while learning AI and ML, https://youtu.be/M3WcDNj4YJ8?si=2xMBBjqkuBsSoo0c