Challenge - 5 Problems
Signal Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a sine wave with given amplitude and frequency
What is the output array of the following code that generates a sine wave with amplitude 2 and frequency 1 Hz sampled at 4 points?
Signal Processing
import numpy as np fs = 4 # sampling frequency f = 1 # frequency of sine wave A = 2 # amplitude t = np.arange(4) / fs signal = A * np.sin(2 * np.pi * f * t) print(signal)
Attempts:
2 left
💡 Hint
Recall that sine of 0 is 0, sine of pi/2 is 1, sine of pi is 0, sine of 3pi/2 is -1.
✗ Incorrect
The sine wave values at t=0, 0.25, 0.5, 0.75 seconds with frequency 1 Hz and amplitude 2 are 0, 2, 0, -2 respectively.
❓ data_output
intermediatePhase shift effect on sine wave values
Given a sine wave with amplitude 1, frequency 1 Hz, sampled at 4 points, what is the output array if the phase is shifted by pi/2?
Signal Processing
import numpy as np fs = 4 f = 1 A = 1 phase = np.pi / 2 t = np.arange(4) / fs signal = A * np.sin(2 * np.pi * f * t + phase) print(signal)
Attempts:
2 left
💡 Hint
Phase shift by pi/2 turns sine into cosine.
✗ Incorrect
Adding a phase of pi/2 shifts sine wave to cosine wave, so values at t=0,0.25,0.5,0.75 are cos(0)=1, cos(pi/2)=0, cos(pi)=-1, cos(3pi/2)=0.
❓ visualization
advancedVisualizing amplitude change on sine wave
Which plot correctly shows the effect of increasing amplitude from 1 to 3 on a sine wave with frequency 1 Hz?
Signal Processing
import numpy as np import matplotlib.pyplot as plt fs = 100 f = 1 t = np.linspace(0, 1, fs, endpoint=False) signal1 = 1 * np.sin(2 * np.pi * f * t) signal2 = 3 * np.sin(2 * np.pi * f * t) plt.plot(t, signal1, label='Amplitude 1') plt.plot(t, signal2, label='Amplitude 3') plt.legend() plt.show()
Attempts:
2 left
💡 Hint
Amplitude controls the height of the wave peaks.
✗ Incorrect
Increasing amplitude scales the wave vertically, so the second wave peaks are three times higher than the first.
🧠 Conceptual
advancedEffect of frequency on sine wave period
If the frequency of a sine wave doubles, what happens to its period?
Attempts:
2 left
💡 Hint
Period is the inverse of frequency.
✗ Incorrect
Period is 1 divided by frequency, so doubling frequency halves the period.
🔧 Debug
expertIdentify error in phase shift calculation
What error does the following code produce when trying to apply a phase shift of 90 degrees to a sine wave?
import numpy as np
fs = 10
f = 1
A = 1
phase = 90
t = np.arange(fs) / fs
signal = A * np.sin(2 * np.pi * f * t + phase)
print(signal)
Signal Processing
import numpy as np fs = 10 f = 1 A = 1 phase = 90 t = np.arange(fs) / fs signal = A * np.sin(2 * np.pi * f * t + phase) print(signal)
Attempts:
2 left
💡 Hint
Check units of phase in trigonometric functions.
✗ Incorrect
Numpy sine function expects phase in radians; 90 degrees must be converted to pi/2 radians.
