Bird
Raised Fist0
Signal Processingdata~20 mins

Sampling theorem (Nyquist-Shannon) in Signal Processing - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Sampling Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Nyquist Frequency

What is the Nyquist frequency for a signal with a maximum frequency component of 5 kHz?

A10 kHz
B20 kHz
C5 kHz
D2.5 kHz
Attempts:
2 left
💡 Hint

Nyquist frequency is twice the highest frequency component in the signal.

❓ Predict Output
intermediate
2:00remaining
Sampling a Sine Wave Signal

What is the output array when sampling a 1 Hz sine wave at 5 Hz for 5 samples?

Signal Processing
import numpy as np
fs = 5  # sampling frequency in Hz
f = 1   # signal frequency in Hz
t = np.arange(5) / fs
samples = np.sin(2 * np.pi * f * t)
print(np.round(samples, 3))
A[0.0, 0.309, 0.809, 0.809, 0.309]
B[0.0, 0.588, 0.951, 0.951, 0.588]
C[0.0, 1.0, 0.0, -1.0, 0.0]
D[0.0, 0.951, 0.588, -0.588, -0.951]
Attempts:
2 left
💡 Hint

Calculate sine values at t = 0, 0.2, 0.4, 0.6, 0.8 seconds.

❓ data_output
advanced
2:00remaining
Effect of Undersampling on Signal Reconstruction

Given a 7 kHz signal sampled at 10 kHz, what is the frequency of the aliased signal observed after sampling?

A7 kHz
B10 kHz
C3 kHz
D17 kHz
Attempts:
2 left
💡 Hint

Aliased frequency = |sampling frequency - original frequency| when undersampled.

❓ visualization
advanced
2:30remaining
Visualizing Aliasing Effect

Which plot correctly shows the original 6 Hz sine wave and its sampled version at 8 Hz, demonstrating aliasing?

Signal Processing
import numpy as np
import matplotlib.pyplot as plt

fs = 8
f = 6
t_cont = np.linspace(0, 1, 1000)
signal_cont = np.sin(2 * np.pi * f * t_cont)
t_samp = np.arange(0, 1, 1/fs)
signal_samp = np.sin(2 * np.pi * f * t_samp)

plt.figure(figsize=(8,4))
plt.plot(t_cont, signal_cont, label='Original Signal (6 Hz)')
plt.stem(t_samp, signal_samp, linefmt='r-', markerfmt='ro', basefmt='k-', label='Sampled Signal (8 Hz)')
plt.legend()
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title('Aliasing Demonstration')
plt.show()
APlot shows continuous 6 Hz sine wave and sampled points at 8 Hz with visible distortion (aliasing).
BPlot shows continuous 6 Hz sine wave and sampled points at 12 Hz with no aliasing.
CPlot shows continuous 6 Hz sine wave and sampled points at 6 Hz with perfect reconstruction.
DPlot shows continuous 8 Hz sine wave and sampled points at 6 Hz with aliasing.
Attempts:
2 left
💡 Hint

Sampling below twice the signal frequency causes aliasing visible as distortion.

🚀 Application
expert
3:00remaining
Determining Minimum Sampling Rate for Mixed Signals

You have a signal composed of three sine waves at 1 kHz, 3 kHz, and 4.5 kHz. What is the minimum sampling frequency to sample this signal without aliasing?

A4.5 kHz
B9 kHz
C10 kHz
D13.5 kHz
Attempts:
2 left
💡 Hint

Minimum sampling frequency must be at least twice the highest frequency component.

Practice

(1/5)
1. What does the Nyquist-Shannon sampling theorem state about the sampling rate?
easy
A. Sample at the same rate as the highest frequency
B. Sample at half the highest frequency of the signal
C. Sample at any random rate
D. Sample at least twice the highest frequency of the signal

Solution

  1. Step 1: Understand the sampling theorem

    The Nyquist-Shannon theorem says to sample at least twice the highest frequency to capture all information.
  2. Step 2: Identify correct sampling rate

    Sampling below twice the highest frequency causes aliasing and loss of information.
  3. Final Answer:

    Sample at least twice the highest frequency of the signal -> Option D
  4. Quick Check:

    Sampling rate ≥ 2 x highest frequency [OK]
Hint: Remember: sample rate must be double highest frequency [OK]
Common Mistakes:
  • Thinking sampling rate can be less than highest frequency
  • Confusing sampling rate with signal frequency
  • Ignoring aliasing effects
2. Which of the following is the correct Python syntax to calculate the Nyquist frequency for a signal with sampling rate fs?
easy
A. nyquist = fs / 2
B. nyquist = fs * 2
C. nyquist = 2 / fs
D. nyquist = fs + 2

Solution

  1. Step 1: Recall Nyquist frequency formula

    The Nyquist frequency is half the sampling rate, so nyquist = fs / 2.
  2. Step 2: Match formula to options

    Only nyquist = fs / 2 correctly divides fs by 2.
  3. Final Answer:

    nyquist = fs / 2 -> Option A
  4. Quick Check:

    Nyquist frequency = sampling rate / 2 [OK]
Hint: Nyquist frequency is half the sampling rate [OK]
Common Mistakes:
  • Multiplying instead of dividing by 2
  • Confusing Nyquist frequency with sampling rate
  • Using addition or reciprocal incorrectly
3. Given a signal with highest frequency 500 Hz, what is the minimum sampling rate to avoid aliasing? Consider the code:
highest_freq = 500
sampling_rate = ?
medium
A. sampling_rate = 1000
B. sampling_rate = 750
C. sampling_rate = 250
D. sampling_rate = 500

Solution

  1. Step 1: Apply Nyquist theorem to highest frequency

    Minimum sampling rate = 2 x highest frequency = 2 x 500 = 1000 Hz.
  2. Step 2: Compare with options

    Only sampling_rate = 1000 matches 1000 Hz.
  3. Final Answer:

    sampling_rate = 1000 -> Option A
  4. Quick Check:

    Minimum sampling rate = 2 x 500 = 1000 [OK]
Hint: Double the highest frequency for minimum sampling rate [OK]
Common Mistakes:
  • Choosing sampling rate equal to highest frequency
  • Selecting a rate less than twice the frequency
  • Confusing frequency units
4. Identify the error in this Python code snippet that calculates the Nyquist frequency:
fs = 800
nyquist = fs * 0.5
print("Nyquist frequency is", nyquist)
medium
A. The multiplication should be division by 2
B. The variable fs should be lowercase
C. The code is correct and will print 400.0
D. The print statement syntax is wrong

Solution

  1. Step 1: Understand calculation of Nyquist frequency

    Nyquist frequency = sampling rate divided by 2, which equals fs * 0.5.
  2. Step 2: Check code correctness

    Code multiplies fs by 0.5 correctly and prints the value 400.0.
  3. Final Answer:

    The code is correct and will print 400.0 -> Option C
  4. Quick Check:

    fs * 0.5 = 400.0, print works fine [OK]
Hint: Multiplying by 0.5 equals dividing by 2 [OK]
Common Mistakes:
  • Thinking multiplication by 0.5 is wrong
  • Assuming variable case matters here
  • Believing print syntax is incorrect in Python 3
5. You have a signal with components up to 1200 Hz. You sample it at 2000 Hz. What problem will occur and why?

Options:
A) No problem, sampling rate is sufficient
B) Aliasing will occur because sampling rate is less than twice highest frequency
C) Aliasing will occur because sampling rate is more than twice highest frequency
D) Signal will be perfectly reconstructed without aliasing
hard
A. No problem, sampling rate is sufficient
B. Aliasing will occur because sampling rate is less than twice highest frequency
C. Aliasing will occur because sampling rate is more than twice highest frequency
D. Signal will be perfectly reconstructed without aliasing

Solution

  1. Step 1: Calculate minimum sampling rate needed

    Minimum sampling rate = 2 x 1200 Hz = 2400 Hz.
  2. Step 2: Compare given sampling rate with minimum

    Given sampling rate is 2000 Hz, which is less than 2400 Hz, so aliasing will occur.
  3. Step 3: Understand aliasing cause

    Sampling below twice the highest frequency causes signal distortion called aliasing.
  4. Final Answer:

    Aliasing will occur because sampling rate is less than twice highest frequency -> Option B
  5. Quick Check:

    Sampling rate < 2 x highest frequency causes aliasing [OK]
Hint: Sampling rate must be ≥ 2 x highest frequency to avoid aliasing [OK]
Common Mistakes:
  • Assuming 2000 Hz is enough for 1200 Hz signal
  • Confusing aliasing cause with oversampling
  • Thinking aliasing occurs when sampling rate is too high
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard