BasicsIndependenceGoogleMetaJane Street
Problem
Given a list of probabilities probs for independent events, implement independent_joint_prob(probs) returning the joint probability that all events occur simultaneously (∏pi).
Why It Matters: Independent multiplication governs multi-component system uptime, repeated coin flips, and Naive Bayes likelihoods.
Function Signature
import math
def independent_joint_prob(probs: list[float]) -> float:
Sample Input & Output
Example 1: Three Independent Components All Up
Input:
probs = [0.9, 0.8, 0.5]
Expected Output:
0.36
Explanation: 0.9 * 0.8 * 0.5 = 0.36.
Example 2: One Zero-Probability Event
Input:
probs = [0.95, 0.0, 0.99]
Expected Output:
0.0
Explanation: A single impossible event collapses the joint probability to 0.0.
Constraints & Edge Cases
- Return
floatjoint probability. - Use
math.prod(probs)and cast tofloat. - If any event has probability
0.0, the joint probability is0.0.
Constraints & Evaluation Criteria
- Return `float` joint probability.
Hints
Python 3⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[0.5, 0.5, 0.5]
Expected Output / Criteria
0.125