All problems
Permutation Entropy Small
Problem
Compute normalized permutation entropy. For every window of order points spaced by delay, record the rank order pattern (ties broken by index) and build its empirical distribution; return the Shannon entropy of those patterns divided by log(order!).
Return 0.0 if order < 2, delay < 1, or the series has fewer than (order - 1) * delay + 1 points.
Hint
Monotone series produce a single ordinal pattern, so entropy is zero.
Test cases
case 1
in: [[1,2,3,4,5],2,1]
expected: 0
case 2
in: [[1,2,1,2,1,2],2,1]
expected: 0.9709505944546688
case 3
in: [[3,3,3,3],2,1]
expected: 0
case 4
in: [[5,4,3,2,1],3,1]
expected: 0
Starter codePython
import math
def permutation_entropy(series, order, delay):
# Your code here
pass4 test cases · run your code against them in the editor