Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-152

Whitening Transform

Problem

Apply z-score whitening per dimension: (x - mean) / std.

Dimensions with zero standard deviation become 0.0. The lists are zipped, so the shortest one determines the output length.

Hint

Guard against division by zero before subtracting and dividing.

Test cases

case 1
in: [[2,4],[0,2],[1,2]]
expected: [2,1]
case 2
in: [[1,1],[1,1],[0,0]]
expected: [0,0]
case 3
in: [[0,0],[0,0],[1,1]]
expected: [0,0]
case 4
in: [[3,5,7],[1,1,1],[2,2,2]]
expected: [1,2,3]
Starter codePython
def whitening_transform(vector, mean, std):
    # Your code here
    pass

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