Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-297

Fourier Seasonality Amplitudes

Problem

Compute the amplitude sqrt(a^2 + b^2) for each Fourier harmonic given a list of coefficient pairs, one pair per harmonic.

Amplitudes are non-negative even when the coefficients are negative.

Hint

The pair forms a right triangle whose hypotenuse is the amplitude.

Test cases

case 1
in: [[[3,4]]]
expected: [5]
case 2
in: [[[1,0],[0,2]]]
expected: [1,2]
case 3
in: [[[0,0]]]
expected: [0]
case 4
in: [[]]
expected: []
case 5
in: [[[-3,-4]]]
expected: [5]
Starter codePython
def fourier_seasonality_amplitudes(coeff_pairs):
    # Your code here
    pass

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