Skip to content
DeepForgeby svx
All problems
EasyCalculusca-152

Aliasing Frequency

Problem

When a sinusoid of frequency f is sampled at rate fs, it appears as an alias at the frequency closest to f among the shifts by multiples of fs.

Return the folded frequency |f - fs * round(f / fs)|, which always lies in [0, fs/2].

Hint

Aliasing folds frequencies above the Nyquist limit back into the baseband.

Test cases

case 1
in: [100,60]
expected: 20
case 2
in: [10,100]
expected: 10
case 3
in: [60,100]
expected: 40
case 4
in: [250,100]
expected: 50
case 5
in: [0,50]
expected: 0
Starter codePython
def aliased_frequency(f, fs):
    # Your code here
    pass

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