Bird
Raised Fist0
Signal Processingdata~20 mins

Signal-to-noise ratio (SNR) in Signal Processing - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
SNR Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Calculate SNR from signal and noise arrays
Given the following Python code that calculates the signal-to-noise ratio (SNR) in decibels, what is the output?
Signal Processing
import numpy as np
signal = np.array([2, 4, 6, 8, 10])
noise = np.array([1, 1, 1, 1, 1])
snr = 10 * np.log10(np.mean(signal**2) / np.mean(noise**2))
print(round(snr, 2))
A10.00
B15.00
C20.00
D16.43
Attempts:
2 left
💡 Hint
Remember that SNR in decibels is 10 times the log base 10 of the power ratio.
❓ data_output
intermediate
2:00remaining
Number of samples with SNR above threshold
You have a signal array and noise array. Which option shows the number of samples where the instantaneous SNR (signal power divided by noise power) is greater than 4?
Signal Processing
import numpy as np
signal = np.array([1, 5, 2, 8, 3])
noise = np.array([1, 1, 1, 2, 1])
inst_snr = (signal**2) / (noise**2)
count = np.sum(inst_snr > 4)
print(count)
A3
B2
C4
D1
Attempts:
2 left
💡 Hint
Calculate (signal^2)/(noise^2) for each element and count how many exceed 4.
❓ visualization
advanced
3:00remaining
Plot signal and noise power over time
Which option produces a plot with two lines: signal power and noise power over time, correctly labeled and with a legend?
Signal Processing
import matplotlib.pyplot as plt
import numpy as np
time = np.arange(5)
signal = np.array([2, 4, 6, 8, 10])
noise = np.array([1, 1, 1, 1, 1])
signal_power = signal**2
noise_power = noise**2
plt.plot(time, signal_power, label='Signal Power')
plt.plot(time, noise_power, label='Noise Power')
plt.xlabel('Time')
plt.ylabel('Power')
plt.legend()
plt.show()
ASyntax error due to missing parentheses in plt.show.
BPlots signal_power and noise_power lines with labels and legend correctly shown.
CPlots signal_power only, noise_power missing, no legend.
DPlots noise_power only with incorrect labels, no legend.
Attempts:
2 left
💡 Hint
Check if both lines are plotted and legend is included.
🧠 Conceptual
advanced
1:30remaining
Interpretation of SNR value
If a signal has an SNR of 0 dB, what does this mean about the signal and noise powers?
ASignal power is zero.
BSignal power is ten times noise power.
CSignal power equals noise power.
DNoise power is zero.
Attempts:
2 left
💡 Hint
Recall that SNR in dB = 10 * log10(signal power / noise power).
🔧 Debug
expert
2:00remaining
Identify error in SNR calculation code
What error will the following code produce when calculating SNR, and why? import numpy as np signal = np.array([1, 2, 3]) noise = np.array([0, 0, 0]) snr = 10 * np.log10(np.mean(signal**2) / np.mean(noise**2)) print(snr)
ANo error, prints a very large SNR value.
BTypeError because of unsupported operand types.
CZeroDivisionError because noise power mean is zero.
DValueError due to invalid array shapes.
Attempts:
2 left
💡 Hint
Check the denominator in the division inside log10.

Practice

(1/5)
1. What does Signal-to-Noise Ratio (SNR) measure in signal processing?
easy
A. The strength of the signal compared to the background noise
B. The total power of the noise only
C. The frequency of the signal
D. The duration of the signal

Solution

  1. Step 1: Understand the definition of SNR

    SNR is defined as the ratio of signal power to noise power, showing how strong the signal is compared to noise.
  2. Step 2: Compare options with definition

    Only The strength of the signal compared to the background noise correctly states that SNR measures signal strength relative to noise.
  3. Final Answer:

    The strength of the signal compared to the background noise -> Option A
  4. Quick Check:

    SNR = Signal strength / Noise strength [OK]
Hint: Remember: SNR compares signal power to noise power [OK]
Common Mistakes:
  • Confusing SNR with noise power alone
  • Thinking SNR measures frequency
  • Mixing up signal duration with SNR
2. Which of the following is the correct formula to calculate SNR in decibels (dB)?
easy
A. SNR(dB) = 10 * log10(signal power / noise power)
B. SNR(dB) = signal power / noise power
C. SNR(dB) = 20 * log10(signal power + noise power)
D. SNR(dB) = log10(signal power - noise power)

Solution

  1. Step 1: Recall the SNR formula in decibels

    SNR in dB is calculated as 10 times the base-10 logarithm of the ratio of signal power to noise power.
  2. Step 2: Check each option against the formula

    SNR(dB) = 10 * log10(signal power / noise power) matches the correct formula. Options A, B, and D are incorrect due to missing log, wrong multiplier, or incorrect operations.
  3. Final Answer:

    SNR(dB) = 10 * log10(signal power / noise power) -> Option A
  4. Quick Check:

    SNR(dB) = 10 * log10(Signal/Noise) [OK]
Hint: Use 10 * log10 for power ratios in dB [OK]
Common Mistakes:
  • Using 20 instead of 10 for power ratio
  • Forgetting the logarithm
  • Adding signal and noise instead of dividing
3. Given signal power = 50 and noise power = 2, what is the SNR in decibels (dB)? Use SNR(dB) = 10 * log10(signal power / noise power).
medium
A. 10 * log10(50 + 2) ≈ 17.16 dB
B. 10 * log10(50 / 2) ≈ 13.98 dB
C. 10 * log10(2 / 50) ≈ -13.98 dB
D. 10 * log10(50 - 2) ≈ 16.81 dB

Solution

  1. Step 1: Calculate the ratio of signal power to noise power

    Ratio = 50 / 2 = 25.
  2. Step 2: Calculate 10 * log10(25)

    log10(25) ≈ 1.398, so SNR(dB) = 10 * 1.398 ≈ 13.98 dB.
  3. Final Answer:

    10 * log10(50 / 2) ≈ 13.98 dB -> Option B
  4. Quick Check:

    SNR(dB) = 10 * log10(25) ≈ 13.98 dB [OK]
Hint: Divide signal by noise, then apply 10 * log10 [OK]
Common Mistakes:
  • Adding signal and noise instead of dividing
  • Using log base e instead of log base 10
  • Confusing subtraction with division
4. Identify the error in this Python code calculating SNR in dB:
import math
signal_power = 100
noise_power = 10
snr_db = 10 * math.log(signal_power / noise_power)
print(snr_db)
medium
A. Missing multiplication by 20 instead of 10
B. Dividing noise power by signal power instead of the reverse
C. Using natural log instead of log base 10
D. Not importing the math module

Solution

  1. Step 1: Check the logarithm function used

    The code uses math.log(), which is natural logarithm (base e), but SNR in dB requires log base 10.
  2. Step 2: Identify correct function for log base 10

    Python's math module has math.log10() for base 10 logarithm, which should be used instead.
  3. Final Answer:

    Using natural log instead of log base 10 -> Option C
  4. Quick Check:

    Use math.log10() for dB calculations [OK]
Hint: Use math.log10() for dB, not math.log() [OK]
Common Mistakes:
  • Using math.log() instead of math.log10()
  • Swapping signal and noise in division
  • Confusing multiplication factor (10 vs 20)
5. You have a noisy signal with signal power 200 and noise power 50. You apply a filter that reduces noise power by half but also reduces signal power by 10%. What is the new SNR in dB? Use SNR(dB) = 10 * log10(signal power / noise power).
hard
A. 10 * log10(200 / 50) ≈ 6.02 dB
B. 10 * log10(200 / 25) ≈ 9.03 dB
C. 10 * log10(180 / 50) ≈ 5.56 dB
D. 10 * log10(180 / 25) ≈ 8.57 dB

Solution

  1. Step 1: Calculate new signal and noise powers after filtering

    Signal power reduced by 10%: 200 * 0.9 = 180
    Noise power reduced by half: 50 / 2 = 25
  2. Step 2: Calculate new SNR in dB

    SNR = 10 * log10(180 / 25) = 10 * log10(7.2) ≈ 10 * 0.8573 = 8.57 dB.
  3. Final Answer:

    10 * log10(180 / 25) ≈ 8.57 dB -> Option D
  4. Quick Check:

    New SNR = 10 * log10(7.2) ≈ 8.57 dB [OK]
Hint: Adjust powers first, then apply SNR formula [OK]
Common Mistakes:
  • Not reducing signal power by 10%
  • Not halving noise power
  • Using original powers without changes
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