Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-105

Optional Stopping Expected Value

Problem

A martingale is stopped when it first leaves an interval, hitting up_value with probability p_hit and down_value otherwise. Optional stopping gives the expected stopped value:

E[X_T] = p_hit * up_value + (1 - p_hit) * down_value.

Return the expectation.

Hint

Only the two exit values matter for the stopped expectation.

Test cases

case 1
in: [0.5,1,-1]
expected: 0
case 2
in: [0.6,10,-5]
expected: 4
case 3
in: [1,7,3]
expected: 7
Starter codePython
def optional_stopping_expected_value(p_hit, up_value, down_value):
    # Your code here
    pass

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