What is the minimum sampling frequency required to perfectly reconstruct a signal with a maximum frequency of 5 kHz?
Recall the Nyquist theorem which states the sampling frequency must be at least twice the maximum frequency.
The Nyquist rate is twice the maximum frequency component of the signal. For 5 kHz max frequency, minimum sampling frequency is 10 kHz.
What is the output array when sampling a 1 Hz sine wave at 4 Hz for 1 second?
import numpy as np fs = 4 # sampling frequency f = 1 # signal frequency t = np.arange(0, 1, 1/fs) samples = np.sin(2 * np.pi * f * t) print(np.round(samples, 2))
Calculate sine values at 0, 0.25, 0.5, 0.75 seconds.
Sampling at 4 Hz means samples at every 0.25 seconds. Sine(2π*1*0) = 0, sine(2π*1*0.25) = 1, sine(2π*1*0.5) = 0, sine(2π*1*0.75) = -1.
Given a sampled signal with aliasing, which output array shows the effect of applying an ideal low-pass reconstruction filter?
import numpy as np import matplotlib.pyplot as plt fs = 8 f_signal = 5 t = np.arange(0, 1, 1/fs) sampled = np.sin(2 * np.pi * f_signal * t) + 0.5 * np.sin(2 * np.pi * 3 * t) # Ideal low-pass filter removes frequencies above 4 Hz reconstructed = 0.5 * np.sin(2 * np.pi * 3 * t) print(np.round(reconstructed, 2))
The low-pass filter removes frequency components above 4 Hz, keeping the 3 Hz component.
The 5 Hz component is removed by the filter, leaving only the 3 Hz sine wave scaled by 0.5, resulting in option C.
Which plot correctly shows aliasing when sampling a 7 Hz sine wave at 10 Hz?
import numpy as np import matplotlib.pyplot as plt fs = 10 f = 7 t = np.linspace(0, 1, 1000) signal = np.sin(2 * np.pi * f * t) sampled_t = np.arange(0, 1, 1/fs) sampled_signal = np.sin(2 * np.pi * f * sampled_t) plt.figure(figsize=(8,4)) plt.plot(t, signal, label='Original Signal') plt.stem(sampled_t, sampled_signal, linefmt='r-', markerfmt='ro', basefmt='k-', label='Samples') plt.legend() plt.title('Sampling 7 Hz signal at 10 Hz') plt.xlabel('Time (s)') plt.ylabel('Amplitude') plt.grid(True) plt.show()
Sampling below twice the signal frequency causes aliasing, making the sampled points look like a lower frequency.
Sampling a 7 Hz signal at 10 Hz causes aliasing, making the samples appear as a 3 Hz sine wave (10 - 7 = 3 Hz).
What error will occur when running this reconstruction code snippet?
import numpy as np fs = 8 f = 3 # Sampled signal samples = np.sin(2 * np.pi * f * np.arange(0, 1, 1/fs)) # Reconstruction using sinc interpolation def reconstruct(t, samples, fs): n = np.arange(len(samples)) return np.sum(samples[n] * np.sinc(fs * (t - n / fs))) reconstructed_signal = [reconstruct(ti, samples, fs) for ti in np.linspace(0, 1, 100)] print(np.round(reconstructed_signal[:5], 2))
Check how the sum function is used with arrays inside the reconstruct function.
The sum function is called with an array argument, but sum expects an iterable of scalars. Using numpy.sum or vectorizing is needed. Also, samples[n] is an array, so samples[n] * np.sinc(...) is an array, sum(...) tries to sum over arrays incorrectly causing TypeError.
