Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-267

Ornstein-Uhlenbeck Conditional Mean

Problem

The Ornstein-Uhlenbeck process reverts toward mu with rate theta, and its conditional mean is x0 * exp(-theta * t) + mu * (1 - exp(-theta * t)). Return that mean, or 0.0 for theta < 0 or t < 0.

Hint

The initial displacement decays exponentially while the mean pulls back to mu.

Test cases

case 1
in: [1,0,1,1]
expected: 0.36787944117144233
case 2
in: [0,5,2,1]
expected: 4.323323583816936
case 3
in: [3,1,0,5]
expected: 3
case 4
in: [2,2,1,0]
expected: 2
case 5
in: [1,2,0.5,2]
expected: 1.6321205588285577
Starter codePython
import math


def ou_conditional_mean(x0, mu, theta, t):
    # Your code here
    pass

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