All problems
OU Half-Life
Problem
Estimate the half-life of mean reversion for a process whose spread follows an AR(1) with coefficient phi: half_life = -ln(2) / ln(phi).
Return 0.0 when phi is not strictly between 0 and 1, since the spread either does not mean-revert or does not exist.
Hint
The closer phi is to 1, the slower the reversion and the longer the half-life.
Test cases
case 1
in: [0.9]
expected: 6.578813478960585
case 2
in: [0.5]
expected: 1
case 3
in: [0.99]
expected: 68.96756393652842
case 4
in: [1]
expected: 0
Starter codePython
import math
def ou_half_life(phi):
# Your code here
pass4 test cases · run your code against them in the editor