ML Interview Q Series: Calculating Joint Bulb Survival Probability Using PDF Integration
Browse all the Probability Interview Questions here.
Find the probability that none of the three bulbs will have to be replaced during the first 1200 hours of operation if each bulb’s lifetime X (in thousands of hours) has the probability density function 6[0.25 − (x − 1.5)²] for 1 ≤ x ≤ 2, and 0 otherwise. Assume the lifetimes of different bulbs are independent.
Short Compact solution
For a single bulb, the probability that it lasts beyond 1.2 (i.e. 1200 hours) is 0.8960. Therefore, the probability that none of the three bulbs fails before 1200 hours is 0.8960³ = 0.7193.
Comprehensive Explanation
PDF Definition and Domain
The lifetime X of a bulb is measured in thousands of hours (so 1.2 in the problem corresponds to 1200 hours). We are given the probability density function (pdf) for X:
and f(x) = 0 otherwise. Here:
x is the lifetime in thousands of hours.
The expression 0.25 - (x - 1.5)² describes a parabola that is positive only in the range 1 ≤ x ≤ 2.
The factor 6 ensures the total integral over 1 ≤ x ≤ 2 is 1 (making it a valid pdf).
Probability That a Single Bulb Survives Beyond 1200 Hours
We want P(X > 1.2). Formally:
Within 1 ≤ x ≤ 2, we can compute this definite integral. One way is to find the antiderivative of 6[0.25 - (x - 1.5)²], then evaluate it at 1.2 and 2. Without going into every minor arithmetic step, the final numerical result is:
P(X > 1.2) = 0.8960.
Probability That None of Three Bulbs Fails Before 1200 Hours
Because each bulb’s lifetime is assumed to be independent, the probability that all three bulbs last beyond 1.2 is simply:
Probability for a single bulb to last beyond 1.2, raised to the third power.
Hence,
P(no bulbs replaced by 1200 hours) = (0.8960)³ = 0.7193.
Follow-up question 1
How do we verify that the given pdf is valid?
A valid pdf f(x) must satisfy two conditions:
f(x) ≥ 0 for all x in the domain.
The integral of f(x) over its entire domain is 1.
Here, the pdf is 6[0.25 − (x − 1.5)²] for 1 ≤ x ≤ 2 and 0 otherwise. To confirm it is valid:
First, we check that within 1 ≤ x ≤ 2, the expression 0.25 − (x − 1.5)² is nonnegative (because 1 ≤ x ≤ 2 lies exactly around the peak 1.5, so (x − 1.5)² ≤ 0.25). Outside this range, the pdf is 0, which is certainly nonnegative.
Second, we compute the integral from 1 to 2 of the function 6[0.25 − (x − 1.5)²]. If that integral equals 1, the function is a valid pdf.
If you go through the integral:
∫ from x=1 to x=2 of 6[0.25 − (x − 1.5)²] dx = 1,
confirming the pdf is indeed properly normalized.
Why it matters: Ensuring a function is a valid pdf is crucial in probability theory so that subsequent probabilities (like P(X > 1.2)) are consistent with a proper probability measure.
Follow-up question 2
How could we compute this probability in a practical data-science or ML setting without symbolic integration?
One common approach is to perform a numerical approximation or simulation:
Numerical Integration
Use a numerical integration library (e.g.,
scipy.integrate.quad
in Python) to compute ∫ from 1.2 to 2 of 6[0.25 − (x − 1.5)²] dx.This would give a numerical estimate for P(X > 1.2).
Monte Carlo Simulation
Generate a large number of random samples from X’s distribution using an acceptance–rejection sampling method (since the pdf is known explicitly) or any standard sampling approach.
Estimate P(X > 1.2) by the fraction of samples whose value exceeds 1.2.
Example: Python code for numerical integration
import numpy as np
from scipy.integrate import quad
def pdf(x):
# pdf is nonzero for 1 <= x <= 2
if 1 <= x <= 2:
return 6 * (0.25 - (x - 1.5)**2)
else:
return 0
prob, _ = quad(pdf, 1.2, 2) # Integrate from 1.2 to 2
print(prob) # Should be approximately 0.8960
These approaches are invaluable in real-world data science scenarios where an exact symbolic form of an integral may be complicated or unknown, and numerical/empirical methods provide reliable answers.
Follow-up question 3
What if the question asked for the probability that at least one bulb fails before 1200 hours?
The complement rule is often used in such contexts:
“At least one bulb fails before 1200 hours” = 1 − (All bulbs survive beyond 1200 hours).
If P(X > 1.2) = 0.8960 for a single bulb, then P(all survive) = 0.8960³.
Hence P(at least one fails) = 1 − 0.8960³ = 1 − 0.7193 = 0.2807.
In many interview or real-life probability questions, you might be asked for the probability that at least one failure occurs, because that scenario is often more operationally relevant (e.g., “What is the chance we need a replacement?").
Follow-up question 4
Why is independence critical here, and how would it change if the lifetimes were correlated?
The independence assumption ensures that the joint probability factorizes into the product of individual probabilities:
P(X₁ > 1.2, X₂ > 1.2, X₃ > 1.2) = P(X₁ > 1.2) × P(X₂ > 1.2) × P(X₃ > 1.2).
If the bulbs’ lifetimes were correlated, we could not simply multiply their individual survival probabilities. We would need to know the joint distribution or correlation structure. For example:
Positive correlation might increase the chance that if one bulb fails early, others might fail early, so P(all survive) could become higher or lower depending on the nature of that correlation.
Negative correlation could mean that if one fails early, the others might last longer, or vice versa.
In a real-world engineering or ML context, correlation of failure times can happen if bulbs share environmental factors. Handling such dependencies requires advanced modeling (e.g., copulas, multivariate survival models).
Follow-up question 5
Could we generalize this to an arbitrary time threshold T?
Yes. If we replace 1.2 by some t (still in thousands of hours) within the interval [1,2], the approach is identical:
Calculate P(X > t) = ∫ from t to 2 of 6[0.25 − (x − 1.5)²] dx, for 1 ≤ t ≤ 2.
Then P(no replacements by t) = (P(X > t))³, assuming independence.
If t < 1, then P(X > t) = 1 because the domain of X is [1, 2], so the probability is trivially 1 for each bulb if t < 1. If t > 2, P(X > t) = 0, meaning every bulb will fail by that time because the maximum lifetime allowed by the model is 2000 hours.
Follow-up question 6
How might real maintenance schedules differ from a purely probabilistic approach?
In practice, traffic lights might get preventive maintenance based on:
Manufacturer recommendations (e.g., recommended to replace after a certain guaranteed lifetime).
Historical data of real-world failure patterns that might show different aging behavior than the theoretical distribution suggests.
Safety margins: a city might decide to replace bulbs earlier than strictly needed to avoid risks of simultaneous outages.
Hence, while the probability calculation helps in understanding the fraction of bulbs likely to fail by a certain time, real maintenance schedules often incorporate additional engineering and safety constraints.