All problems
Z-Normalized Shape Distance
Problem
Compute the Euclidean distance between two series after z-normalizing each: subtract the mean and divide by the population standard deviation (a constant series becomes all zeros).
Return None if the series have different lengths or are empty.
Hint
Z-normalization removes level and scale, leaving only shape.
Test cases
case 1
in: [[1,2,3],[2,4,6]]
expected: 0
case 2
in: [[1,2,3,4],[1,4,9,16]]
expected: 0.35356426632003163
case 3
in: [[1,1,1],[1,2,3]]
expected: 1.7320508075688772
case 4
in: [[1,2,3],[3,2,1]]
expected: 3.4641016151377544
Starter codePython
def z_normalized_distance(x, y):
# Your code here
pass4 test cases · run your code against them in the editor