All problems
Approximate Entropy Lite
Problem
Compute approximate entropy with embedding dimension m and tolerance r. For each length mm in {m, m+1} form all overlapping templates and compute C_i = (number of templates within Chebyshev distance r of template i) / (number of templates), counting self-matches; phi(mm) is the mean of log(C_i). The result is phi(m) - phi(m+1).
Return 0.0 if m < 1 or the series is shorter than m + 2.
Hint
Small approximate entropy means the series is highly predictable.
Test cases
case 1
in: [[1,2,1,2,1,2],2,0]
expected: 0.020135513550688988
case 2
in: [[1,2,3,4,5],1,0]
expected: -0.2231435513142097
case 3
in: [[3,3,3,3],2,0]
expected: 0
case 4
in: [[1,2,1,2,1,2],1,1]
expected: 0
Starter codePython
import math
def approximate_entropy(series, m, r):
# Your code here
pass4 test cases · run your code against them in the editor