Sampling helps us turn continuous signals into numbers so computers can understand them. Reconstruction lets us get back the original signal from those numbers.
Sampling and reconstruction in communication in Signal Processing
sampled_signal = sample(original_signal, sampling_rate) reconstructed_signal = reconstruct(sampled_signal, reconstruction_method)
sample() means taking values from the original signal at regular time steps.
reconstruct() means using those samples to rebuild the signal, often with interpolation.
sampled_signal = sample(sin_wave, 1000) # sample sine wave at 1000 Hz reconstructed_signal = reconstruct(sampled_signal, 'sinc')
sampled_signal = sample(audio_signal, 44100) # CD quality audio sampling reconstructed_signal = reconstruct(sampled_signal, 'linear')
This code creates a 5 Hz sine wave as the original signal. It samples this signal at 50 Hz, which is enough to capture the wave properly (above twice the frequency). Then it reconstructs the signal by holding each sample value until the next one (zero-order hold). The plot shows the original, sampled points, and reconstructed signal.
import numpy as np import matplotlib.pyplot as plt # Create a continuous signal: 5 Hz sine wave fs_continuous = 5000 # high sampling for 'continuous' simulation t = np.linspace(0, 1, fs_continuous, endpoint=False) signal = np.sin(2 * np.pi * 5 * t) # Sample the signal at 50 Hz (below Nyquist for 5 Hz signal) fs_sample = 50 sample_points = np.arange(0, 1, 1/fs_sample) sampled_signal = np.sin(2 * np.pi * 5 * sample_points) # Reconstruct signal using zero-order hold (step function) reconstructed_signal = np.repeat(sampled_signal, fs_continuous//fs_sample) reconstructed_signal = reconstructed_signal[:len(signal)] # Plot all signals plt.figure(figsize=(10, 6)) plt.plot(t, signal, label='Original Signal (5 Hz sine)') plt.stem(sample_points, sampled_signal, linefmt='r-', markerfmt='ro', basefmt=' ', label='Sampled Points (50 Hz)') plt.plot(t, reconstructed_signal, 'g--', label='Reconstructed Signal (Zero-Order Hold)') plt.legend() plt.xlabel('Time (seconds)') plt.ylabel('Amplitude') plt.title('Sampling and Reconstruction Example') plt.grid(True) plt.show()
Sampling rate must be at least twice the highest frequency in the signal to avoid losing information (Nyquist rate).
Reconstruction methods like sinc interpolation give better results than simple zero-order hold.
In real communication, signals are often noisy, so filtering is important before sampling.
Sampling converts continuous signals into discrete numbers for digital use.
Reconstruction rebuilds the continuous signal from these samples.
Choosing the right sampling rate and reconstruction method is key to keeping signal quality.
Practice
Solution
Step 1: Understand the role of sampling
Sampling takes a continuous-time signal and measures its amplitude at discrete time intervals.Step 2: Identify the purpose in communication
This process allows the signal to be represented digitally for processing and transmission.Final Answer:
To convert a continuous signal into discrete values -> Option AQuick Check:
Sampling = Continuous to discrete conversion [OK]
- Confusing sampling with filtering
- Thinking sampling increases signal strength
- Mixing sampling with encryption
f_max?Solution
Step 1: Recall Nyquist theorem
The Nyquist rate states the sampling frequency must be greater than twice the highest frequency in the signal.Step 2: Apply to formula
So,f_s > 2 * f_maxensures no loss of information during sampling.Final Answer:
f_s > 2 * f_max -> Option BQuick Check:
Nyquist rate = 2 * max frequency [OK]
- Using sampling rate less than max frequency
- Confusing less than and greater than signs
- Ignoring the factor of 2 in Nyquist rate
f_max = 3000 f_s = 2 * f_max print(f_s)
Solution
Step 1: Calculate minimum sampling frequency
Using Nyquist, minimum sampling frequency is twice the max frequency: 2 * 3000 = 6000 Hz.Step 2: Check Python code output
The code multiplies 3000 by 2 and prints 6000, matching the calculation.Final Answer:
6000 -> Option AQuick Check:
2 * 3000 = 6000 [OK]
- Printing max frequency instead of double
- Dividing instead of multiplying
- Confusing units (Hz vs kHz)
import numpy as np
def reconstruct_signal(samples, t, T):
x_recon = 0
for n in range(len(samples)):
x_recon += samples[n] * np.sinc((t - n*T))
return x_recon
# samples = [1, 2, 3], t = 1.5, T = 1
print(reconstruct_signal([1, 2, 3], 1.5, 1))Solution
Step 1: Understand np.sinc function
In numpy, np.sinc(x) = sin(pi*x)/(pi*x), so input is already normalized by pi.Step 2: Check argument passed to np.sinc
The code passes (t - n*T) directly, which is correct because np.sinc expects normalized input.Step 3: Identify error
Actually, the argument is correct; the error is that x_recon is initialized as 0 (a scalar), but the function expects to handle array inputs for t for vectorized reconstruction.Step 4: Correct error
x_recon should be initialized as np.zeros_like(t) if t is an array, but since t is scalar here, initialization is fine.Step 5: Reconsider options
np.sinc argument should be normalized by pi says argument should be normalized by pi, but numpy's sinc already does that, so no need to normalize.Step 6: Final conclusion
No error in normalization; the code is correct for scalar t. The main issue is if t is array, initialization fails.Final Answer:
x_recon should be initialized as an array, not zero -> Option CQuick Check:
Accumulator initialization must match output type [OK]
- Assuming np.sinc needs manual pi normalization
- Initializing accumulator incorrectly for arrays
- Confusing loop variable roles
Solution
Step 1: Compare sampling rate and Nyquist rate
Nyquist rate = 2 * max frequency = 2 * 5 kHz = 10 kHz. Sampling rate is 8 kHz, which is less than Nyquist rate.Step 2: Identify consequence of insufficient sampling
Sampling below Nyquist rate causes aliasing, where higher frequencies appear as lower frequencies, distorting the signal.Step 3: Determine solution
To avoid aliasing, increase sampling rate above 10 kHz.Final Answer:
Aliasing will occur; fix by increasing sampling rate above 10 kHz -> Option DQuick Check:
Sampling rate < Nyquist rate causes aliasing [OK]
- Assuming 8 kHz is enough for 5 kHz max frequency
- Confusing noise with aliasing
- Ignoring Nyquist sampling theorem
Ready to prove it?
Pass the test and this pattern moves unknown
