|
242 | 242 | "source": [ |
243 | 243 | "(Task_B2_3_3)=\n", |
244 | 244 | "#### Task B3: Aliasing and the Nyquist frequency \n", |
| 245 | + "```{tip}\n", |
| 246 | + "This section goes a little deeper into the maths behind sampling, so don't worry if you don't understand everything. The idea is that you have some intuition for where the Nyquist frequency comes from\n", |
| 247 | + "```\n", |
245 | 248 | "If a higher sampling frequency results in a more accurate reconstruction, then why can't we always sample with a very high sampling frequency? The thing is, there is always a trade-off between our ability to store data and the quality of our reconstruction. If you increase your sampling frequency, the quality of your reconstruction may improve, but as you have recorded more data points, you have more data to store. So what is the minimum sampling frequency needed to accurately reconstruct the original signal, and what happens if we sample at a sampling frequency lower than this?\n", |
246 | 249 | "\n", |
247 | | - "To understand this, we have to take a look at what happens in the frequency domain when we sample a signal. Lets imagine we have an arbritrary signal called $x(t)$ that we're interested in sampling. As seen in the figure below, if we take the Fourier transform of this signal, we can see what frequencies its made up of (note: both the signal $x(t)$ and its Fourier transform are entirely made up and are simply used for the purpose of explanation). \n", |
| 250 | + "To understand this, we have to take a look at what happens in the frequency domain when we sample a signal. Lets imagine we have an arbritrary signal called $x(t)$ that we're interested in sampling. As seen in the figure below, if we take the Fourier transform of this signal, we can see which frequencies it's made up of, or in other words, its frequency spectrum. \n", |
| 251 | + "\n", |
| 252 | + "```{note}\n", |
| 253 | + "Both the signal $x(t)$ and its Fourier transform are entirely made up and are simply used for the purpose of explanation\n", |
| 254 | + "```\n", |
248 | 255 | "\n", |
249 | 256 | "```{figure} images/signal_bandlimited.png\n", |
250 | 257 | "---\n", |
251 | | - "width: 800px\n", |
| 258 | + "width: 700px\n", |
252 | 259 | "name: bandlimited_signal\n", |
253 | 260 | "---\n", |
254 | 261 | "A signal $x(t)$ and its Fourier transform\n", |
255 | 262 | "```\n", |
256 | | - "Notably, in the frequency domain, we can see that this signal has a maximum frequency $f_{m}$ and because it's symmetrical about the origin, a minimum frequency of $-f_{m}$. Mathematically, in the time domain, sampling corresponds to multiplying our signal $x(t)$ by a train of delta pulses separated by the sampling interval ($T_{s}=\\frac{1}{f_{s}}$). \n", |
| 263 | + "Notably, in the frequency domain, we can see that this signal has a maximum frequency $f_{m}$ and because it's symmetrical about the origin, a minimum frequency of $-f_{m}$. \n", |
| 264 | + "\n", |
| 265 | + "Mathematically, in the time domain, sampling corresponds to multiplying our original signal $x(t)$ by a train of delta pulses (essentially an infinitely tall and skinny pulse) separated by the sampling interval ($T_{s}=\\frac{1}{f_{s}}$). This makes sense if we think of it intuitively: if we multiply our original signal by pulses spaced out by the sampling interval, then everywhere where the product is 0, we will have nothing and at multiples of the sampling interval, we will have pulses with amplitudes corresponding to that of our original signal. Hence, this multiplication creates a sample of the original signal.\n", |
| 266 | + "\n", |
| 267 | + "```{figure} images/sampling_pulse_train.png\n", |
| 268 | + "---\n", |
| 269 | + "width: 900px\n", |
| 270 | + "name: sampling_time_domain\n", |
| 271 | + "---\n", |
| 272 | + "Sampling in the time domain corresponds to multiplying the original signal by a train of delta pulses separated by the sampling interval $T_{s}=\\frac{1}{f_{s}}$.\n", |
| 273 | + "```\n", |
| 274 | + "\n", |
| 275 | + "But what happens in the frequency domain when we do this? Multiplying our original signal by a train of delta pulses in the time domain essentially copies the original frequency spectrum and pastes it around multiples of the sampling frequency. \n", |
| 276 | + "\n", |
| 277 | + "```{figure} images/freq_domain_sampling.png\n", |
| 278 | + "---\n", |
| 279 | + "width: 700px\n", |
| 280 | + "name: freq_domain_sampling\n", |
| 281 | + "---\n", |
| 282 | + "In the frequency domain, sampling a signal creates copies of the original frequency spectrum pasted around multiples of the sampling frequency\n", |
| 283 | + "```\n", |
| 284 | + "If we want to create a reconstruction of our original signal, we simply isolate the original frequency spectrum. \n", |
| 285 | + "\n", |
| 286 | + "```{figure} images/reconstruction.png\n", |
| 287 | + "---\n", |
| 288 | + "width: 900px\n", |
| 289 | + "name: reconstruction \n", |
| 290 | + "---\n", |
| 291 | + "To create a reconstruction of the original signal, the original frequency spectrum is isolated\n", |
| 292 | + "```\n", |
| 293 | + "We said before that a higher sampling frequency $f_{s}$ leads to a better quality reconstruction, but how does this idea fit into all of this? If we increase $f_{s}$, then our copies of the original frequency spectrum will be separated further from each other, meaning it's easier to reconstruct the original signal. However, if we decrease $f_{s}$ too much, then the copies of the original frequency spectrum will overlap causing distortion. This effect is referred to as aliasing. When this happens, because there is no longer a full copy of the original frequency spectrum, it is not possible to reconstruct the original signal. As we say, the higher frequency components in the original signal have been aliased. \n", |
| 294 | + "\n", |
| 295 | + "```{figure} images/below_nyquist_freq.png\n", |
| 296 | + "---\n", |
| 297 | + "width: 600px\n", |
| 298 | + "name: below_nyquist \n", |
| 299 | + "---\n", |
| 300 | + "If the sampling frequency is too low, the frequency spectrums start to overlap causing distortion. This means that the original frequency spectrum is lost, so reconstruction is no longer possible.\n", |
| 301 | + "```\n", |
| 302 | + "So what is our limit for the lowest possible sampling frequency where reconstruction is still possible without aliasing? Reconstruction is possible until the upper edge of one copy exactly coincides with the lower edge of another copy. In the image below, lets look at the frequency spectrum centred around the origin and the copy centred around $f_{s}$. The right-most point on the original is $f_{m}$ and the left-most point on the copy is $f_{s}-f_{m}$. Hence the lowest sampling frequency for which reconstruction is still possible occurs when $f_{m}=f_{s}-f_{m}$. Rearranging, we obtain:\n", |
| 303 | + "\n", |
| 304 | + "$$f_{s}=2f_{m}$$\n", |
| 305 | + "\n", |
| 306 | + "So, this means that the lowest possible sampling frequency we can use to still obtain a reconstruction of the original signal is 2 times the highest frequency component of the original signal. \n", |
| 307 | + "\n", |
| 308 | + "This formula is often written in a different form as:\n", |
| 309 | + "\n", |
| 310 | + "$$f_{N}=\\frac{f_{s}}{2}$$\n", |
| 311 | + "\n", |
| 312 | + "This formula says that the maximum frequency that can be measured without aliasing, (the Nyquist frequency $f_{N}$) is half of the sampling frequency. Any frequency above the Nyquist frequency will experience aliasing, like what is shown in [this](below_nyquist) figure. \n", |
| 313 | + "\n", |
| 314 | + "All of this theory helps us to choose an appropriate sampling frequencing, so our reconstruction doesn't have distortion/aliasing. This is important when sampling electronic signals, when recording audios and also when taking photos and videos. The video below gives an example of the effects of aliasing when recording a video of a spinning fan. If the sampling frequency of the camera is smaller than two times the maximum frequency of the fan, then the video will contain aliasing, that makes it look like the fan is spinning backwards. \n", |
| 315 | + "\n", |
| 316 | + "```{video} https://www.youtube.com/watch?v=fk0pU0Vg7QA\n", |
| 317 | + "```" |
| 318 | + ] |
| 319 | + }, |
| 320 | + { |
| 321 | + "cell_type": "markdown", |
| 322 | + "id": "0d70dc42", |
| 323 | + "metadata": {}, |
| 324 | + "source": [ |
| 325 | + "### Anticipate\n", |
| 326 | + "\n", |
| 327 | + "#### Task A1: Sampling of sine wave by hand\n", |
| 328 | + "Give students example so they know how to approach \n", |
| 329 | + "Make them sample a sine wave by hand and connect the dots\n", |
257 | 330 | "\n", |
258 | | - "* Higher sampling frequency - better reconstruction of original signal\n", |
259 | | - "* Trade-off bc of limitations in data storage \n", |
260 | | - "* Include triangle diagram \n", |
261 | | - "* Explain sampling with a pulse train \n", |
262 | | - "* Maybe mention that original signal must be bandlimited to reconstruct\n", |
| 331 | + "#### Task A2: Questions about choosing appropriate sampling frequency\n", |
| 332 | + "Give example + numerical solution \n", |
263 | 333 | "\n", |
264 | | - "* Explain concept\n", |
265 | | - "* Give formulas\n", |
266 | | - "* Mention phase " |
| 334 | + "#### Task A3: Make them devise a method to prevent aliasing" |
267 | 335 | ] |
268 | 336 | }, |
269 | 337 | { |
|
0 commit comments