All problems
Effective Sample Size from Autocorrelation
Problem
Return the effective sample size n*(1 - rho1)/(1 + rho1) for a series with lag-1 autocorrelation rho1. Return 0.0 when n <= 0 or rho1 is not in (-1, 1].
Hint
Positive autocorrelation reduces the information each observation carries.
Test cases
case 1
in: [100,0.5]
expected: 33.333333333333336
case 2
in: [100,0]
expected: 100
case 3
in: [100,-0.5]
expected: 300
case 4
in: [50,1]
expected: 0
case 5
in: [10,-1]
expected: 0
Starter codePython
def effective_sample_size(n, rho1):
# Your code here
pass5 test cases · run your code against them in the editor