Independent Events Joint Probability

Basics
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\prod p_i).

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 float joint probability.
  • Use math.prod(probs) and cast to float.
  • If any event has probability 0.0, the joint probability is 0.0.

Constraints & Evaluation Criteria

  • Return `float` joint probability.

Hints

Python 3
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[0.5, 0.5, 0.5]
Expected Output / Criteria
0.125