Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-362

Rotation-Based Outlier Smoothing

Problem

Smooth outlier channels with a Givens rotation: rotate each consecutive pair (x[2i], x[2i+1]) by angle_rad in radians, y[2i] = c*x[2i] - s*x[2i+1] and y[2i+1] = s*x[2i] + c*x[2i+1]. An odd trailing element is copied unchanged.

The signature is rotation_outlier_smoothing(x, angle_rad).

Hint

Rotating an outlier spreads its magnitude across channels, shrinking amax.

Test cases

case 1
in: [[1,0],0.7853981633974483]
expected: [0.7071067811865476,0.7071067811865475]
case 2
in: [[100,0],0.7853981633974483]
expected: [70.71067811865476,70.71067811865474]
case 3
in: [[1,0,5],0]
expected: [1,0,5]
case 4
in: [[0,0],1.5707963267948966]
expected: [0,0]
Starter codePython
import math
def rotation_outlier_smoothing(x, angle_rad):
    # Your code here
    pass

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