Bird
Raised Fist0
Signal Processingdata~10 mins

Sampling theorem (Nyquist-Shannon) in Signal Processing - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Sampling theorem (Nyquist-Shannon)
Start: Analog Signal
↓
Determine Max Frequency f_max
↓
Calculate Sampling Rate f_s >= 2*f_max
↓
Sample Signal at f_s
↓
Reconstruct Signal from Samples
↓
Check: No Information Loss?
↓
Perfect Reconstruction
↓
End
The theorem guides sampling an analog signal at twice its highest frequency to avoid losing information and enable perfect reconstruction.
Execution Sample
Signal Processing
f_max = 1000  # max frequency in Hz
f_s = 2 * f_max  # minimum sampling rate
samples = sample_signal(signal, f_s)
reconstructed = reconstruct_signal(samples, f_s)
This code samples a signal at twice its max frequency and reconstructs it to check for loss.
Execution Table
StepVariable/ActionValue/ConditionResult/Output
1Identify max frequency f_maxf_max = 1000 HzMax frequency set
2Calculate sampling rate f_sf_s = 2 * f_max = 2000 HzSampling rate set to 2000 Hz
3Sample signal at f_sSampling at 2000 samples/secSamples collected without aliasing
4Reconstruct signal from samplesUsing samples and f_sSignal reconstructed perfectly
5Check if f_s < 2*f_maxIf f_s < 2000 HzAliasing occurs, info lost
6Check if f_s >= 2*f_maxIf f_s >= 2000 HzPerfect reconstruction possible
7EndSampling and reconstruction doneProcess complete
💡 Process stops after sampling and reconstruction; if sampling rate is below twice max frequency, aliasing occurs.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
f_maxundefined1000 Hz1000 Hz1000 Hz1000 Hz
f_sundefined2000 Hz2000 Hz2000 Hz2000 Hz
samplesnonenonecollectedcollectedcollected
reconstructednonenonenoneperfect signalperfect signal
Key Moments - 3 Insights
Why must the sampling rate be at least twice the max frequency?
Because if the sampling rate is less than twice the max frequency (see execution_table step 5), aliasing happens and the signal cannot be perfectly reconstructed.
What happens if we sample exactly at twice the max frequency?
Sampling exactly at twice the max frequency (step 2) is the minimum rate to avoid aliasing, allowing perfect reconstruction as shown in step 4.
Why do we check the condition f_s >= 2*f_max after sampling?
To confirm if the sampling rate is sufficient to avoid information loss; if not, aliasing occurs (step 5), otherwise perfect reconstruction is possible (step 6).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of f_s after step 2?
A500 Hz
B1000 Hz
C2000 Hz
D4000 Hz
💡 Hint
Check the 'Calculate sampling rate f_s' row in the execution_table.
At which step does aliasing occur if the sampling rate is too low?
AStep 5
BStep 3
CStep 4
DStep 6
💡 Hint
Look for the step checking if f_s < 2*f_max in the execution_table.
If f_s is increased to 4000 Hz, how does the variable_tracker change for f_s?
Af_s remains 2000 Hz after step 2
Bf_s changes to 4000 Hz after step 2
Cf_s changes to 1000 Hz after step 2
Df_s becomes undefined
💡 Hint
Refer to variable_tracker row for f_s and imagine changing the calculation in step 2.
Concept Snapshot
Sampling theorem (Nyquist-Shannon):
- Sample rate f_s must be at least twice max frequency f_max
- f_s >= 2*f_max avoids aliasing
- Sampling below this causes info loss
- Perfect reconstruction possible if condition met
- Key for digital signal processing
Full Transcript
The Sampling theorem, also called Nyquist-Shannon theorem, says to capture an analog signal without losing information, you must sample it at least twice as fast as its highest frequency. This minimum rate is called the Nyquist rate. If you sample slower, different frequencies mix up (aliasing), and you cannot get the original signal back perfectly. The process starts by finding the max frequency in the signal, then setting the sampling rate to twice that. Sampling happens at this rate, and then the signal is reconstructed from these samples. If the sampling rate is correct, the reconstruction matches the original signal exactly. Otherwise, information is lost. This theorem is the foundation of converting real-world signals into digital form safely.

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