Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-236

Conditional Expected Lifetime Given Survival

Problem

The exponential distribution is memoryless, so given that a component has already survived s time units, the expected remaining lifetime is still 1 / lam. Return the conditional expected total lifetime E[X | X > s] = s + 1 / lam. Return 0.0 for lam <= 0 or s < 0.

Hint

Add the elapsed time s to the constant residual mean 1 / lam.

Test cases

case 1
in: [1,2]
expected: 3
case 2
in: [0.5,4]
expected: 6
case 3
in: [2,0]
expected: 0.5
case 4
in: [0.25,0]
expected: 4
Starter codePython
def exponential_conditional_lifetime(lam, s):
    # Your code here
    pass

4 test cases · run your code against them in the editor