Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-204

Correlation Dimension Lite

Problem

Estimate the correlation dimension from the slope of the log-log correlation integral. For each positive radius r, C(r) is the fraction of point pairs with abs(x[i] - x[j]) <= r; return (ln C(r_last) - ln C(r_first)) / (ln r_last - ln r_first) using the first and last radii with nonzero C.

Return 0.0 when fewer than two such radii exist.

Hint

The slope of the correlation integral on a log-log plot estimates the dimension.

Test cases

case 1
in: [[1,2,4,8],[1,2,4,8]]
expected: 0.8616541669070521
case 2
in: [[1,2,3,4],[0.5,1,2]]
expected: 0.7369655941662062
case 3
in: [[5,5,5],[1,2]]
expected: 0
case 4
in: [[1,2],[1,2]]
expected: 0
Starter codePython
import math
def correlation_dimension_lite(series, radii):
    # Your code here
    pass

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