1 00:00:17,290 --> 00:00:20,200 MICHALE FEE: OK, good morning, everyone. 2 00:00:20,200 --> 00:00:23,680 So today, we're going to continue with our plan 3 00:00:23,680 --> 00:00:28,030 for developing a powerful set of tools 4 00:00:28,030 --> 00:00:30,400 for analyzing the temporal structure of signals, 5 00:00:30,400 --> 00:00:34,780 in particular a periodic structure and signals. 6 00:00:34,780 --> 00:00:38,020 And so this was the outline that we 7 00:00:38,020 --> 00:00:40,990 had for this series of three lectures. 8 00:00:40,990 --> 00:00:44,740 Last time, we covered Fourier series, complex Fourier series, 9 00:00:44,740 --> 00:00:47,810 and the Fourier transform, discrete Fourier transform. 10 00:00:47,810 --> 00:00:51,820 And we started talking about the power spectrum. 11 00:00:51,820 --> 00:00:53,680 And in that section, we described 12 00:00:53,680 --> 00:00:58,050 how you can take any function and write it as a-- 13 00:00:58,050 --> 00:01:00,100 or any periodic function and write it 14 00:01:00,100 --> 00:01:04,780 as a sum of sinusoidal component. 15 00:01:04,780 --> 00:01:09,220 So even functions we can write down as a sum of cosines. 16 00:01:09,220 --> 00:01:12,640 And odd functions we can write down as a sum of sines. 17 00:01:12,640 --> 00:01:15,410 Today, we're going to continue with that. 18 00:01:15,410 --> 00:01:18,250 We're going to talk about the convolution theorem, noise 19 00:01:18,250 --> 00:01:20,820 and filtering Shannon-Nyquist sampling theorem 20 00:01:20,820 --> 00:01:22,018 and spectral estimation. 21 00:01:22,018 --> 00:01:23,560 And next time, we're going to move on 22 00:01:23,560 --> 00:01:30,310 to spectrograms and an important idea of windowing and tapering, 23 00:01:30,310 --> 00:01:34,660 time bandwidth product, and some more advanced filtering 24 00:01:34,660 --> 00:01:36,460 methods. 25 00:01:36,460 --> 00:01:39,760 So last time, I gave you this little piece of code 26 00:01:39,760 --> 00:01:44,260 that allows you to compute the discrete Fourier transform 27 00:01:44,260 --> 00:01:47,530 using this Matlab function FFT. 28 00:01:47,530 --> 00:01:53,140 And we talked about how in order to do this properly, 29 00:01:53,140 --> 00:01:55,390 you should first circularly shift. 30 00:01:55,390 --> 00:01:59,680 You have to take the time series. 31 00:01:59,680 --> 00:02:01,840 And actually, the FFT algorithm is 32 00:02:01,840 --> 00:02:04,660 expecting the first half of the data in the second half 33 00:02:04,660 --> 00:02:06,580 of that data vector. 34 00:02:06,580 --> 00:02:07,510 Don't ask me why. 35 00:02:07,510 --> 00:02:11,650 But we just do a circular shift, run the FFT. 36 00:02:11,650 --> 00:02:17,470 And then circular shift again to get the negative frequencies 37 00:02:17,470 --> 00:02:19,300 in the first half of the vector. 38 00:02:19,300 --> 00:02:22,870 And then you can plot the Fourier transform 39 00:02:22,870 --> 00:02:23,950 of your function. 40 00:02:23,950 --> 00:02:25,480 This shows an example where we took 41 00:02:25,480 --> 00:02:27,620 a cosine as a function of time. 42 00:02:27,620 --> 00:02:29,590 At some frequency, here, 20 hertz. 43 00:02:29,590 --> 00:02:32,180 We compute the Fourier transform of that and plot that. 44 00:02:32,180 --> 00:02:34,390 So that's what this looks like. 45 00:02:34,390 --> 00:02:37,360 Here is a cosine at 20 hertz. 46 00:02:37,360 --> 00:02:41,890 And you can see if you take the fast Fourier transform of that, 47 00:02:41,890 --> 00:02:44,530 you can see that what you see is the real part 48 00:02:44,530 --> 00:02:45,655 as a function of frequency. 49 00:02:45,655 --> 00:02:50,890 It has two peaks, one at plus 20 hertz, one at minus 20 hertz. 50 00:02:50,890 --> 00:02:53,290 And the imaginary part is 0. 51 00:02:53,290 --> 00:02:55,750 So we have two peaks. 52 00:02:55,750 --> 00:02:58,810 One produces a complex exponential 53 00:02:58,810 --> 00:03:02,650 that goes around the unit circle like this at 20 hertz. 54 00:03:02,650 --> 00:03:05,560 The other peak produces a complex exponential 55 00:03:05,560 --> 00:03:08,520 that goes around the other way at 20 hertz. 56 00:03:08,520 --> 00:03:11,260 The imaginary parts cancel and leave you 57 00:03:11,260 --> 00:03:15,940 with a real part that goes back and forth at 20 hertz OK? 58 00:03:15,940 --> 00:03:19,560 So that's what those two peaks are doing. 59 00:03:19,560 --> 00:03:26,130 Here is the Fourier transform of a sine wave at 20 hertz. 60 00:03:26,130 --> 00:03:30,270 This is phase shifted so the cosine is a symmetric function 61 00:03:30,270 --> 00:03:31,740 or an even function. 62 00:03:31,740 --> 00:03:33,713 The sine is an odd function. 63 00:03:33,713 --> 00:03:35,130 And you can see that in this case, 64 00:03:35,130 --> 00:03:37,770 the Fourier transform again has two peaks. 65 00:03:37,770 --> 00:03:41,280 In this case, the real part is 0. 66 00:03:41,280 --> 00:03:43,730 And the two peaks are in the imaginary part. 67 00:03:43,730 --> 00:03:47,640 The one at plus 20 hertz is minus I. 68 00:03:47,640 --> 00:03:50,670 And the one at minus 20 hertz is plus I. 69 00:03:50,670 --> 00:03:53,490 Now, the interesting thing here, the key thing, 70 00:03:53,490 --> 00:03:56,010 is that when you take the Fourier 71 00:03:56,010 --> 00:04:00,960 transform of a function, symmetric functions, even 72 00:04:00,960 --> 00:04:03,390 functions, are always real. 73 00:04:03,390 --> 00:04:06,150 The Fourier transform of even functions is always real. 74 00:04:06,150 --> 00:04:08,760 The Fourier transform, if you will, 75 00:04:08,760 --> 00:04:12,480 the Fourier series of the even part 76 00:04:12,480 --> 00:04:15,770 of the function into the real part of the Fourier transform 77 00:04:15,770 --> 00:04:19,290 and the Fourier series of the odd part 78 00:04:19,290 --> 00:04:22,320 of the function into the imaginary part of the Fourier 79 00:04:22,320 --> 00:04:23,080 transform. 80 00:04:23,080 --> 00:04:23,580 OK? 81 00:04:26,810 --> 00:04:31,100 Now, we introduced the idea of a power spectrum, where we just 82 00:04:31,100 --> 00:04:32,670 take the Fourier transform. 83 00:04:32,670 --> 00:04:36,380 And we take the square magnitude of that Fourier transform. 84 00:04:36,380 --> 00:04:39,410 And you can see that the power spectrum of the sine and cosine 85 00:04:39,410 --> 00:04:42,350 function is just a single peak at the frequency of the sine 86 00:04:42,350 --> 00:04:44,100 or cosine. 87 00:04:44,100 --> 00:04:45,680 OK? 88 00:04:45,680 --> 00:04:50,180 And you can see why that is because the sine and cosine 89 00:04:50,180 --> 00:04:53,330 have a peak at plus 20 hertz. 90 00:04:53,330 --> 00:04:56,100 For the cosine, it's real. 91 00:04:56,100 --> 00:04:58,370 And for the sine, it's imaginary. 92 00:04:58,370 --> 00:05:01,130 But the square magnitude of both of those 93 00:05:01,130 --> 00:05:03,740 is 1 at that frequency. 94 00:05:03,740 --> 00:05:05,657 OK, any questions about that? 95 00:05:05,657 --> 00:05:07,490 Feel like I didn't say that quite as clearly 96 00:05:07,490 --> 00:05:09,610 as I could have? 97 00:05:09,610 --> 00:05:10,270 OK. 98 00:05:10,270 --> 00:05:13,890 So any questions about this? 99 00:05:13,890 --> 00:05:17,000 OK, let's take a look at another function 100 00:05:17,000 --> 00:05:20,370 that we've been talking about, a square wave. 101 00:05:20,370 --> 00:05:25,110 In this case, you can see that the square wave is symmetric 102 00:05:25,110 --> 00:05:26,070 or even. 103 00:05:26,070 --> 00:05:30,040 And you can see that the Fourier transform of that is all real. 104 00:05:30,040 --> 00:05:33,330 The peaks are in the real part of the Fourier transform. 105 00:05:33,330 --> 00:05:36,520 You can see the imaginary part in red is 0 everywhere. 106 00:05:36,520 --> 00:05:38,670 And you can see that the Fourier transform of this 107 00:05:38,670 --> 00:05:44,400 has multiple peaks at intervals that 108 00:05:44,400 --> 00:05:48,480 are again equal to the frequency of this square wave. 109 00:05:48,480 --> 00:05:50,050 OK? 110 00:05:50,050 --> 00:05:52,840 If you look at the power spectrum of the square wave, 111 00:05:52,840 --> 00:05:55,870 you can see again it's got multiple peaks 112 00:05:55,870 --> 00:05:59,620 at regular intervals. 113 00:05:59,620 --> 00:06:01,870 One thing that you often find when 114 00:06:01,870 --> 00:06:04,180 you look at power spectra of functions 115 00:06:04,180 --> 00:06:09,760 is that some of the peaks are very low amplitude or very low 116 00:06:09,760 --> 00:06:10,850 power. 117 00:06:10,850 --> 00:06:13,600 So one of the things that we often 118 00:06:13,600 --> 00:06:15,610 do when we're plotting power spectra 119 00:06:15,610 --> 00:06:19,240 is to plot not power here but log power. 120 00:06:19,240 --> 00:06:20,050 OK? 121 00:06:20,050 --> 00:06:25,850 And so we plot power in log base 10. 122 00:06:25,850 --> 00:06:31,990 A difference of an order of magnitude in two peaks 123 00:06:31,990 --> 00:06:34,960 corresponds to a unit called a bel, b-e-l. 124 00:06:39,096 --> 00:06:45,010 So 1 bel corresponds to a factor of 10 difference in power. 125 00:06:45,010 --> 00:06:48,000 So you can see this peak here is about 1 bel lower 126 00:06:48,000 --> 00:06:51,180 than that peak, right? 127 00:06:51,180 --> 00:06:55,830 And more commonly used unit is called decibels, 128 00:06:55,830 --> 00:06:59,490 which are 10 decibels per bel. 129 00:06:59,490 --> 00:07:05,250 So decibels are given by 10 times the log 130 00:07:05,250 --> 00:07:10,380 base 10 of the power of the square magnitude of the Fourier 131 00:07:10,380 --> 00:07:11,825 transform. 132 00:07:11,825 --> 00:07:12,700 Does that make sense. 133 00:07:12,700 --> 00:07:13,460 Yes. 134 00:07:13,460 --> 00:07:18,160 AUDIENCE: So [INAUDIBLE] square magnitude [INAUDIBLE] 135 00:07:18,160 --> 00:07:20,040 so just like [INAUDIBLE] 136 00:07:20,040 --> 00:07:24,350 MICHALE FEE: No, so you take this square magnitude because-- 137 00:07:24,350 --> 00:07:26,980 OK, remember, last time we talked about power. 138 00:07:26,980 --> 00:07:31,080 So if you have an electrical signal, the power in the signal 139 00:07:31,080 --> 00:07:33,590 would be voltage squared over resistance. 140 00:07:36,270 --> 00:07:38,610 Power, when you refer to signals, 141 00:07:38,610 --> 00:07:42,180 is often kind of used synonymously with variance. 142 00:07:42,180 --> 00:07:46,170 And variance is also goes as the square of the signal. 143 00:07:46,170 --> 00:07:47,820 Now, because the Fourier transform 144 00:07:47,820 --> 00:07:51,640 is a complex number, what we do is we don't just square it, 145 00:07:51,640 --> 00:07:53,880 but we take the squared magnitude. 146 00:07:53,880 --> 00:07:56,610 So we're measuring the distance from the origin 147 00:07:56,610 --> 00:07:59,079 in the complex plane. 148 00:07:59,079 --> 00:08:00,560 OK? 149 00:08:00,560 --> 00:08:02,080 Good question. 150 00:08:02,080 --> 00:08:05,460 All right, any questions about this and what 151 00:08:05,460 --> 00:08:09,280 the meaning of decibels is? 152 00:08:09,280 --> 00:08:16,660 So if a signal had 10 times as much amplitude, 153 00:08:16,660 --> 00:08:20,305 the power would be how much larger? 154 00:08:23,512 --> 00:08:27,490 If you had 10 times as much amplitude, 155 00:08:27,490 --> 00:08:31,730 how much increased power would there be? 156 00:08:31,730 --> 00:08:32,559 100 times. 157 00:08:32,559 --> 00:08:34,900 Which is how many bels? 158 00:08:34,900 --> 00:08:37,870 Log base 10 of 100 is 2. 159 00:08:37,870 --> 00:08:40,732 How many decibels? 160 00:08:40,732 --> 00:08:41,610 AUDIENCE: 22? 161 00:08:41,610 --> 00:08:44,610 MICHALE FEE: No, it's 10 decibels per bel. 162 00:08:44,610 --> 00:08:48,120 Deci just means a tenth of, right? 163 00:08:48,120 --> 00:08:51,590 Remember those units? 164 00:08:51,590 --> 00:08:56,390 So a factor of 10 in signal is a factor of 100 165 00:08:56,390 --> 00:08:59,645 in power, which is 2 bels, which is 20 decibels. 166 00:09:04,410 --> 00:09:04,910 OK. 167 00:09:07,720 --> 00:09:11,560 All right, now I just want to show you one important thing 168 00:09:11,560 --> 00:09:14,790 about Fourier transforms. 169 00:09:14,790 --> 00:09:17,350 There's an interesting property about scaling 170 00:09:17,350 --> 00:09:18,770 in time and frequency. 171 00:09:18,770 --> 00:09:23,672 So if you have a signal like this that's periodic at about-- 172 00:09:23,672 --> 00:09:24,880 I don't know, it looks like-- 173 00:09:24,880 --> 00:09:27,205 OK, there it is-- about 5 hertz. 174 00:09:27,205 --> 00:09:29,080 If you look at the Fourier transform of that, 175 00:09:29,080 --> 00:09:34,120 you can see a series of peaks, because it's a periodic signal. 176 00:09:34,120 --> 00:09:37,510 Now, if you take that same function 177 00:09:37,510 --> 00:09:41,080 and you make it go faster-- 178 00:09:41,080 --> 00:09:44,700 so now, it's at about 10 hertz, instead of 5 hertz, 179 00:09:44,700 --> 00:09:48,930 you can see that the Fourier transform is exactly the same. 180 00:09:48,930 --> 00:09:50,760 It's just scaled out. 181 00:09:50,760 --> 00:09:55,670 So the faster something moves in time, the more stretched 182 00:09:55,670 --> 00:09:57,725 out the frequencies are. 183 00:09:57,725 --> 00:09:59,730 Does that makes sense. 184 00:09:59,730 --> 00:10:03,770 So if I show you any periodic function at one frequency 185 00:10:03,770 --> 00:10:06,860 and I show you the Fourier transform of it, 186 00:10:06,860 --> 00:10:09,380 you can immediately write down the Fourier transform 187 00:10:09,380 --> 00:10:13,780 of any scaled version of that function, 188 00:10:13,780 --> 00:10:18,610 because if this goes faster, if this same function but 189 00:10:18,610 --> 00:10:21,730 at a higher frequency, you can write down the Fourier 190 00:10:21,730 --> 00:10:23,890 transform just by taking this Fourier transform 191 00:10:23,890 --> 00:10:26,918 and stretching it out by that same factor. 192 00:10:26,918 --> 00:10:27,418 OK? 193 00:10:31,440 --> 00:10:35,310 All right, so that was just a brief review 194 00:10:35,310 --> 00:10:37,270 of what we covered last time. 195 00:10:37,270 --> 00:10:40,410 And here's what we're going to cover today 196 00:10:40,410 --> 00:10:41,560 in a little more detail. 197 00:10:41,560 --> 00:10:45,000 So we're going to talk some more about the idea of Fourier 198 00:10:45,000 --> 00:10:47,050 transform pairs. 199 00:10:47,050 --> 00:10:49,710 These are functions where you have a function. 200 00:10:49,710 --> 00:10:52,102 You take the Fourier transform of it. 201 00:10:52,102 --> 00:10:53,310 You get a different function. 202 00:10:53,310 --> 00:10:55,590 If you take the Fourier transform of that, 203 00:10:55,590 --> 00:10:57,670 you go back to the original function. 204 00:10:57,670 --> 00:11:00,090 OK, so there are pairs of functions that are essentially 205 00:11:00,090 --> 00:11:02,440 for transforms of each other. 206 00:11:02,440 --> 00:11:03,160 OK? 207 00:11:03,160 --> 00:11:05,200 An example of that you saw here. 208 00:11:05,200 --> 00:11:08,220 A square wave like this has a Fourier transform 209 00:11:08,220 --> 00:11:11,460 that's this funny function a set of peaks. 210 00:11:11,460 --> 00:11:13,110 If you take the four transform of that, 211 00:11:13,110 --> 00:11:15,320 you would get this square wave. 212 00:11:15,320 --> 00:11:15,820 OK? 213 00:11:18,367 --> 00:11:20,700 We're going to talk about the convolution theorem, which 214 00:11:20,700 --> 00:11:22,717 is a really cool theorem. 215 00:11:22,717 --> 00:11:25,050 Convolution in the time domain looks like multiplication 216 00:11:25,050 --> 00:11:26,790 in the frequency domain. 217 00:11:26,790 --> 00:11:28,350 Multiplication in the time domain 218 00:11:28,350 --> 00:11:30,730 looks like convolution in the frequency domain. 219 00:11:30,730 --> 00:11:37,900 And it allows you to take a set of Fourier transform pairs 220 00:11:37,900 --> 00:11:42,030 that you know, that we'll learn, and figure out 221 00:11:42,030 --> 00:11:46,080 what the Fourier transform is of any function that's either 222 00:11:46,080 --> 00:11:48,810 a product of those or a convolution of those kind 223 00:11:48,810 --> 00:11:50,990 of base functions. 224 00:11:50,990 --> 00:11:54,768 It's a very powerful theorem. 225 00:11:54,768 --> 00:11:56,310 We're going to talk about the Fourier 226 00:11:56,310 --> 00:11:59,950 transform a Gaussian noise and this power spectrum of Gaussian 227 00:11:59,950 --> 00:12:00,450 noise. 228 00:12:00,450 --> 00:12:04,110 We'll talk about how to do spectral estimation. 229 00:12:04,110 --> 00:12:08,040 And we'll end up on the Shannon-Nyquist theorem 230 00:12:08,040 --> 00:12:08,850 and zero padding. 231 00:12:08,850 --> 00:12:10,725 And there may be, if there's time at the end, 232 00:12:10,725 --> 00:12:14,160 I'll talk about a little trick for removing the line 233 00:12:14,160 --> 00:12:17,450 noise from signals. 234 00:12:17,450 --> 00:12:20,250 OK, so let's start with Fourier transform pairs. 235 00:12:20,250 --> 00:12:22,530 So one of the most important functions 236 00:12:22,530 --> 00:12:28,260 to know the Fourier transform of is a square pulse like this. 237 00:12:28,260 --> 00:12:30,780 So let's just take a function of time. 238 00:12:30,780 --> 00:12:33,540 It's 0 everywhere, 0 everywhere. 239 00:12:33,540 --> 00:12:38,670 But it's 1 if the time is within the interval plus delta 240 00:12:38,670 --> 00:12:41,270 t over 2 to minus delta t over 2, 241 00:12:41,270 --> 00:12:43,730 OK, so a square pulse like that. 242 00:12:43,730 --> 00:12:45,330 And let's just take the case where 243 00:12:45,330 --> 00:12:47,638 delta t is 100 milliseconds. 244 00:12:50,984 --> 00:12:53,660 The Fourier transform of a square pulse 245 00:12:53,660 --> 00:12:56,630 is a function called the sinc function. 246 00:12:56,630 --> 00:12:58,610 It looks a little bit messy. 247 00:12:58,610 --> 00:13:03,770 But it's basically a sine wave that 248 00:13:03,770 --> 00:13:07,070 is weighted so that it's big in the middle 249 00:13:07,070 --> 00:13:10,130 and it decreases as you move away from 0. 250 00:13:10,130 --> 00:13:12,080 And it decreases as 1/f. 251 00:13:14,730 --> 00:13:17,580 So this is frequency along this axis. 252 00:13:17,580 --> 00:13:20,310 It's just imagine that you have a sine wave that 253 00:13:20,310 --> 00:13:23,940 gets smaller as you go away from the origin by an amount 1 254 00:13:23,940 --> 00:13:24,690 over f. 255 00:13:24,690 --> 00:13:25,410 That's all it is. 256 00:13:29,010 --> 00:13:33,820 Now, really important concept here, remember, 257 00:13:33,820 --> 00:13:37,820 we talked about how you can take a function of time. 258 00:13:37,820 --> 00:13:40,120 So once you know that the Fourier transform 259 00:13:40,120 --> 00:13:43,840 of a square wave, of this square wave of with 100 milliseconds, 260 00:13:43,840 --> 00:13:45,220 is a sinc function. 261 00:13:45,220 --> 00:13:46,990 You know what the Fourier transform 262 00:13:46,990 --> 00:13:52,210 is of a square pulse that's longer. 263 00:13:52,210 --> 00:13:52,710 Right? 264 00:13:52,710 --> 00:13:53,220 What is it? 265 00:13:57,710 --> 00:14:00,230 Remember, if you just take a function in time 266 00:14:00,230 --> 00:14:02,480 and you stretch it out, the Fourier transform 267 00:14:02,480 --> 00:14:05,290 just does what? 268 00:14:05,290 --> 00:14:06,340 It compresses. 269 00:14:06,340 --> 00:14:06,850 It shrinks. 270 00:14:06,850 --> 00:14:10,450 And if you take this pulse and you make it narrower in time, 271 00:14:10,450 --> 00:14:13,480 then the Fourier transform just stretches out. 272 00:14:13,480 --> 00:14:15,940 So if we take that pulse and we make 273 00:14:15,940 --> 00:14:20,770 it narrower, 25 milliseconds, then 274 00:14:20,770 --> 00:14:23,060 you can see that the sinc function, 275 00:14:23,060 --> 00:14:27,670 it's the same sinc function, but it's just stretched out 276 00:14:27,670 --> 00:14:28,720 in the frequency domain. 277 00:14:32,120 --> 00:14:34,930 So you can see that here if it's 10 milliseconds, 278 00:14:34,930 --> 00:14:36,790 the width of this is 12 hertz. 279 00:14:36,790 --> 00:14:40,240 The full width at half max of that peak is 12 hertz. 280 00:14:40,240 --> 00:14:45,340 If this is 4 times narrower, then this width 281 00:14:45,340 --> 00:14:48,610 will be 4 times wider. 282 00:14:48,610 --> 00:14:51,040 What happens if we have a pulse here that 283 00:14:51,040 --> 00:14:54,070 is 500 milliseconds longer? 284 00:14:54,070 --> 00:14:58,930 So 5 times longer, what's the width of the sinc function 285 00:14:58,930 --> 00:14:59,650 here going to be? 286 00:15:03,760 --> 00:15:07,000 It'll be five times narrower than this, 287 00:15:07,000 --> 00:15:10,370 so a little over 2 hertz. 288 00:15:10,370 --> 00:15:11,895 OK? 289 00:15:11,895 --> 00:15:13,860 Does that makes sense. 290 00:15:13,860 --> 00:15:18,360 So you should remember this Fourier 291 00:15:18,360 --> 00:15:21,420 transform pair, a square pulse and a sinc function. 292 00:15:27,220 --> 00:15:31,620 And there's a very important concept called the time 293 00:15:31,620 --> 00:15:32,850 bandwidth product. 294 00:15:32,850 --> 00:15:38,610 You can see that as you make the width in time narrower, 295 00:15:38,610 --> 00:15:43,700 the bandwidth in frequency gets bigger. 296 00:15:43,700 --> 00:15:46,700 And as you make the pulse in time longer, 297 00:15:46,700 --> 00:15:48,890 the bandwidth gets smaller. 298 00:15:48,890 --> 00:15:52,790 And it turns out that the product of the width in time 299 00:15:52,790 --> 00:15:57,640 and the width in frequency is just a constant. 300 00:15:57,640 --> 00:16:06,450 And for this square pulse sinc function, that constant is 1.2. 301 00:16:06,450 --> 00:16:10,070 So there's a limit. 302 00:16:10,070 --> 00:16:13,810 If you make the square pulse smaller, 303 00:16:13,810 --> 00:16:16,870 the sinc function gets broader. 304 00:16:16,870 --> 00:16:19,180 All right, let's look at a different Fourier transform 305 00:16:19,180 --> 00:16:21,220 pair. 306 00:16:21,220 --> 00:16:24,538 It turns out that the Fourier transform of a Gaussian 307 00:16:24,538 --> 00:16:25,330 is just a Gaussian. 308 00:16:33,940 --> 00:16:38,350 So, here, this Gaussian pulse is 50 milliseconds long. 309 00:16:38,350 --> 00:16:42,100 The Fourier transform of that is a Gaussian pulse 310 00:16:42,100 --> 00:16:44,440 that's 20 hertz wide. 311 00:16:44,440 --> 00:16:48,160 If I make that Gaussian pulses in time narrower, 312 00:16:48,160 --> 00:16:52,180 then the Gaussian in frequency gets wider. 313 00:16:52,180 --> 00:16:56,800 And inversely, if I make the pulse in time wider, 314 00:16:56,800 --> 00:17:01,540 then the Gaussian in frequency space gets narrower. 315 00:17:01,540 --> 00:17:02,422 Yes. 316 00:17:02,422 --> 00:17:06,042 AUDIENCE: I just have a question [INAUDIBLE] 317 00:17:06,042 --> 00:17:06,750 MICHALE FEE: Yes. 318 00:17:06,750 --> 00:17:09,180 AUDIENCE: [INAUDIBLE] 319 00:17:09,180 --> 00:17:10,599 MICHALE FEE: Yep. 320 00:17:10,599 --> 00:17:12,970 So I'm trying-- it's a little bit unclear here, 321 00:17:12,970 --> 00:17:15,849 but I'm measuring these widths at the half height. 322 00:17:20,130 --> 00:17:24,560 OK, and so you can see that for a Gaussian, this time bandwidth 323 00:17:24,560 --> 00:17:27,859 product, delta f times delta t is just 1. 324 00:17:31,320 --> 00:17:34,100 So there's a time bandwidth product of 1. 325 00:17:39,690 --> 00:17:43,080 Who here has taken any quantum mechanics? 326 00:17:43,080 --> 00:17:45,660 Who here has heard of the Heisenberg uncertainty 327 00:17:45,660 --> 00:17:47,240 principle? 328 00:17:47,240 --> 00:17:48,060 Yeah. 329 00:17:48,060 --> 00:17:51,360 This is just the Heisenberg uncertainty principle. 330 00:17:51,360 --> 00:17:53,370 This is where the Heisenberg uncertainty 331 00:17:53,370 --> 00:17:58,640 principle comes from, because wave functions are just-- 332 00:17:58,640 --> 00:18:03,350 you can think of wave functions as just functions in time. 333 00:18:03,350 --> 00:18:04,250 OK? 334 00:18:04,250 --> 00:18:09,780 So the spatial localization of an object is some-- 335 00:18:09,780 --> 00:18:12,650 the wave function is just some position of space. 336 00:18:15,160 --> 00:18:19,600 And the momentum of that particle 337 00:18:19,600 --> 00:18:24,530 can be computed as the Fourier transform of the wave function. 338 00:18:24,530 --> 00:18:29,220 And so if the particle is more lo-- 339 00:18:29,220 --> 00:18:32,820 [AUDIO OUT] in space, then if you compute the Fourier 340 00:18:32,820 --> 00:18:34,800 transform of that wave function, it's 341 00:18:34,800 --> 00:18:37,370 more dispersed in momentum. 342 00:18:37,370 --> 00:18:40,390 OK, so the uncertainty in momentum is larger. 343 00:18:40,390 --> 00:18:43,980 So this concept of time bandwidth product 344 00:18:43,980 --> 00:18:46,800 in the physical world is what gives us the Heisenberg 345 00:18:46,800 --> 00:18:47,800 uncertainty principle. 346 00:18:47,800 --> 00:18:50,570 It's very cool. 347 00:18:50,570 --> 00:18:53,690 Actually, before I go on, you can see that in this case, 348 00:18:53,690 --> 00:18:57,590 the Fourier transform of this function is the same function. 349 00:18:57,590 --> 00:18:59,840 Does anyone remember what a [AUDIO OUT] function 350 00:18:59,840 --> 00:19:02,240 is that the Fourier transform of it 351 00:19:02,240 --> 00:19:05,450 is another version of that same function? 352 00:19:05,450 --> 00:19:07,087 We talked about it last time. 353 00:19:07,087 --> 00:19:08,400 AUDIENCE: Pulse train. 354 00:19:08,400 --> 00:19:11,610 MICHALE FEE: Pulse train, that's right. 355 00:19:11,610 --> 00:19:15,540 So a train of delta functions has a Fourier transform 356 00:19:15,540 --> 00:19:17,790 that's just a train of delta functions. 357 00:19:17,790 --> 00:19:21,180 And 1 over spacing in the time domain 358 00:19:21,180 --> 00:19:23,715 is just equal to 1 over the spacing in the frequency 359 00:19:23,715 --> 00:19:26,300 domain. 360 00:19:26,300 --> 00:19:29,270 So that's another Fourier transform pair 361 00:19:29,270 --> 00:19:31,550 that you should remember. 362 00:19:31,550 --> 00:19:34,810 All right? 363 00:19:34,810 --> 00:19:39,190 OK, convolution theorem. 364 00:19:39,190 --> 00:19:45,490 Imagine that we have three functions of time, y of t, 365 00:19:45,490 --> 00:19:47,740 like this one, y of t. 366 00:19:47,740 --> 00:19:50,580 We could calculate the Fourier transform of that. 367 00:19:50,580 --> 00:19:53,920 And that's capital Y of omega. 368 00:19:53,920 --> 00:19:56,650 And then we have some other function, x of t, 369 00:19:56,650 --> 00:20:00,370 And its Fourier transform, X of omega, 370 00:20:00,370 --> 00:20:04,210 and another function g of tau and its Fourier transform, 371 00:20:04,210 --> 00:20:05,830 capital G of omega. 372 00:20:05,830 --> 00:20:10,780 So remember, we can write down the convolution of this time 373 00:20:10,780 --> 00:20:16,130 series, x with this kernel g as follows. 374 00:20:16,130 --> 00:20:18,280 So in this case, we're defining y 375 00:20:18,280 --> 00:20:21,120 as the convolution of g with x. 376 00:20:21,120 --> 00:20:27,640 So y of t equals this integral d tau g of tau x of t minus tau, 377 00:20:27,640 --> 00:20:30,520 integrating over all tau. 378 00:20:30,520 --> 00:20:34,110 So that's a convolution. 379 00:20:34,110 --> 00:20:41,350 The convolution theorem tells us that the Fourier transform of y 380 00:20:41,350 --> 00:20:45,550 is just the product of the Fourier transform of g 381 00:20:45,550 --> 00:20:47,200 and the Fourier transform of x. 382 00:20:50,040 --> 00:20:53,620 So that, you should remember. 383 00:20:53,620 --> 00:20:54,120 All right? 384 00:20:54,120 --> 00:20:57,960 I'm going to walk you through how you derive that. 385 00:20:57,960 --> 00:20:59,860 I don't expect you to be able to derive it. 386 00:20:59,860 --> 00:21:03,840 But the derivation is kind of cute, and I enjoyed it. 387 00:21:03,840 --> 00:21:06,210 So I thought I'd show you how it goes. 388 00:21:06,210 --> 00:21:09,287 So here's the definition of the convolution. 389 00:21:09,287 --> 00:21:11,370 What we're going to do is we're going to just take 390 00:21:11,370 --> 00:21:13,140 the Fourier transform of y. 391 00:21:13,140 --> 00:21:16,620 So here's how you calculate Fourier transform of something. 392 00:21:16,620 --> 00:21:23,690 Capital Y of omega is just the integral over all time dt y 393 00:21:23,690 --> 00:21:27,440 of t e to the minus i omega t. 394 00:21:27,440 --> 00:21:31,580 So we're going to substitute this into here. 395 00:21:31,580 --> 00:21:32,980 Now, you can see that-- 396 00:21:32,980 --> 00:21:35,360 OK, so the first [AUDIO OUT] is actually reverse 397 00:21:35,360 --> 00:21:36,930 the order of integration. 398 00:21:36,930 --> 00:21:40,700 We're going to integrate over t first rather than tau. 399 00:21:40,700 --> 00:21:42,560 Then what we're going to do is we 400 00:21:42,560 --> 00:21:44,660 can move the g outside the integral 401 00:21:44,660 --> 00:21:47,360 over t, because it's just a function of tau. 402 00:21:47,360 --> 00:21:50,720 So we pull that out. 403 00:21:50,720 --> 00:21:55,520 So now, we have an integral dt x of t minus tau 404 00:21:55,520 --> 00:21:57,770 e to the minus i omega t. 405 00:21:57,770 --> 00:22:00,530 And what we can do is do a little modification here. 406 00:22:00,530 --> 00:22:08,140 We're going to pull an e to the minus i omega tau out of here. 407 00:22:08,140 --> 00:22:10,180 So we have e to the minus i omega 408 00:22:10,180 --> 00:22:13,955 tau times e to the minus j omega t minus tau. 409 00:22:13,955 --> 00:22:16,330 So you can say if you multiply those two things together, 410 00:22:16,330 --> 00:22:18,130 you just get back to that. 411 00:22:22,880 --> 00:22:25,100 Now, what we're going to do is because this 412 00:22:25,100 --> 00:22:28,640 is we're integrating over t, but [AUDIO OUT] a function of tau, 413 00:22:28,640 --> 00:22:32,000 we can pull that out of the integral. 414 00:22:32,000 --> 00:22:35,720 And now we have integral dt x t minus tau 415 00:22:35,720 --> 00:22:38,300 e to the minus i omega t minus tau. 416 00:22:38,300 --> 00:22:40,490 And what do you think that is? 417 00:22:40,490 --> 00:22:42,170 What is that? 418 00:22:42,170 --> 00:22:46,100 What would it be if there were no tau there? 419 00:22:46,100 --> 00:22:50,750 If you just cross that out and that, what would that be? 420 00:22:50,750 --> 00:22:53,140 Anybody know? 421 00:22:53,140 --> 00:22:53,640 What that's? 422 00:22:53,640 --> 00:22:55,190 AUDIENCE: The Fourier transform. 423 00:22:55,190 --> 00:22:59,140 MICHALE FEE: This is just the Fourier transform of x. 424 00:22:59,140 --> 00:22:59,640 Right? 425 00:22:59,640 --> 00:23:03,260 And we're integrating from minus infinity to infinity. 426 00:23:03,260 --> 00:23:07,130 So it does it matter if we're shifting the inside by tau? 427 00:23:07,130 --> 00:23:08,930 No, it doesn't change the answer. 428 00:23:08,930 --> 00:23:11,250 We're integrating from minus infinity to infinity. 429 00:23:11,250 --> 00:23:14,330 So shifting the inside of it by a small amount tau 430 00:23:14,330 --> 00:23:17,750 isn't going to do anything. 431 00:23:17,750 --> 00:23:20,770 So that's just the Fourier transform of x. 432 00:23:20,770 --> 00:23:21,670 Good? 433 00:23:21,670 --> 00:23:24,840 And what is this? 434 00:23:24,840 --> 00:23:26,890 Fourier transform of g. 435 00:23:26,890 --> 00:23:31,910 So the Fourier transform of y is just Fourier transform of g 436 00:23:31,910 --> 00:23:34,180 times the Fourier transform of x. 437 00:23:34,180 --> 00:23:35,720 All right, that's pretty cool. 438 00:23:35,720 --> 00:23:36,380 Kind of cute. 439 00:23:36,380 --> 00:23:38,940 But it's also really powerful. 440 00:23:38,940 --> 00:23:42,670 OK, so let me show you what you can do with that. 441 00:23:42,670 --> 00:23:44,810 First, let me just point out one thing 442 00:23:44,810 --> 00:23:46,510 that there is a convolution theorem that 443 00:23:46,510 --> 00:23:49,620 relates convolution in the time domain 444 00:23:49,620 --> 00:23:52,460 to multiplication in the frequency domain. 445 00:23:52,460 --> 00:23:55,270 You can do exactly the same derivation 446 00:23:55,270 --> 00:24:01,810 and show that convolution of two functions in the frequency 447 00:24:01,810 --> 00:24:04,840 domain is the same as multiplication in the time 448 00:24:04,840 --> 00:24:07,480 domain. 449 00:24:07,480 --> 00:24:09,174 So that's the convolution theorem. 450 00:24:12,570 --> 00:24:17,080 So let's see why that's so powerful. 451 00:24:17,080 --> 00:24:21,583 So I just showed you the Fourier transform of a Gaussian. 452 00:24:21,583 --> 00:24:23,000 So what we're going to do is we're 453 00:24:23,000 --> 00:24:28,830 going to calculate transform of a Gaussian times a sine wave. 454 00:24:28,830 --> 00:24:31,640 So if you take a Gaussian, some window 455 00:24:31,640 --> 00:24:33,320 centered around 0 in time-- this is 456 00:24:33,320 --> 00:24:34,970 a function of time now right? 457 00:24:34,970 --> 00:24:37,130 So there's a little Gaussian pulse in time. 458 00:24:37,130 --> 00:24:39,090 We're going to multiply that by this sine wave. 459 00:24:39,090 --> 00:24:40,650 And when you multiply those together, 460 00:24:40,650 --> 00:24:47,330 you get this little pulse of sine. 461 00:24:47,330 --> 00:24:48,290 OK? 462 00:24:48,290 --> 00:24:51,000 [WHISTLES] Sorry, constant frequency. 463 00:24:51,000 --> 00:24:52,760 Boy, that's harder to do than I thought. 464 00:24:52,760 --> 00:24:56,090 [WHISTLES] OK, just a little pulse of sine wave. 465 00:24:56,090 --> 00:24:58,130 So what's the forehead transform of that? 466 00:24:58,130 --> 00:24:59,330 Well, we don't know, right? 467 00:24:59,330 --> 00:25:01,400 We didn't calculate it. 468 00:25:01,400 --> 00:25:03,770 But you can actually just figure it out very 469 00:25:03,770 --> 00:25:05,840 simply, because you know the Fourier 470 00:25:05,840 --> 00:25:07,260 transform of a Gaussian. 471 00:25:07,260 --> 00:25:08,750 What is that? 472 00:25:08,750 --> 00:25:09,880 A Gaussian. 473 00:25:09,880 --> 00:25:11,938 You know the Fourier transform of a sine wave. 474 00:25:11,938 --> 00:25:12,480 What is that? 475 00:25:15,190 --> 00:25:16,050 Yeah. 476 00:25:16,050 --> 00:25:17,170 Hold it up for me. 477 00:25:17,170 --> 00:25:20,210 What does it look like? 478 00:25:20,210 --> 00:25:22,670 Yes, sine wave, thank you, like this. 479 00:25:22,670 --> 00:25:23,420 OK. 480 00:25:23,420 --> 00:25:25,930 And so what do you know-- 481 00:25:25,930 --> 00:25:29,500 what can you tell me right away what the Fourier 482 00:25:29,500 --> 00:25:31,330 transform of this is? 483 00:25:31,330 --> 00:25:33,050 You take the Fourier transform of that 484 00:25:33,050 --> 00:25:36,500 and can involve it with the Fourier transform of that. 485 00:25:36,500 --> 00:25:37,610 So let's do that. 486 00:25:37,610 --> 00:25:40,780 So there's the Fourier transform of this Gaussian. 487 00:25:40,780 --> 00:25:48,589 If this is 200 milliseconds wide, then how wide is this? 488 00:25:48,589 --> 00:25:49,950 AUDIENCE: [INAUDIBLE] 489 00:25:49,950 --> 00:25:53,250 MICHALE FEE: It's 1 over 200 milliseconds, which is what? 490 00:25:53,250 --> 00:25:54,760 5 hertz, right? 491 00:25:54,760 --> 00:25:57,830 1 over 0.2 is 5. 492 00:25:57,830 --> 00:26:01,610 The Fourier transform of this sine wave-- 493 00:26:01,610 --> 00:26:04,760 and I think I made it a cosine instead of a sine. 494 00:26:04,760 --> 00:26:06,472 Sorry, that's why I was going like this, 495 00:26:06,472 --> 00:26:07,680 and you were going like this. 496 00:26:07,680 --> 00:26:09,950 So I made it a cosine function. 497 00:26:09,950 --> 00:26:13,820 The Fourier transform of the cosine function has two peaks. 498 00:26:13,820 --> 00:26:14,990 This is 20 hertz. 499 00:26:14,990 --> 00:26:17,300 So one peak at 20, one at minus 20. 500 00:26:17,300 --> 00:26:20,320 And the Fourier transform of this 501 00:26:20,320 --> 00:26:24,230 is just the convolution of this with that. 502 00:26:24,230 --> 00:26:31,820 You take this Gaussian and you slide it over those two peaks. 503 00:26:31,820 --> 00:26:37,576 You essentially smooth this with that. 504 00:26:37,576 --> 00:26:38,710 Does that makes sense? 505 00:26:44,370 --> 00:26:44,870 Cool. 506 00:26:44,870 --> 00:26:48,260 So you didn't actually have to stick this into Matlab 507 00:26:48,260 --> 00:26:51,320 and compute the Fourier transform of that. 508 00:26:51,320 --> 00:26:54,510 You can just know in your head that that's 509 00:26:54,510 --> 00:26:58,680 the product of a Gaussian and a sine wave, or cosine. 510 00:26:58,680 --> 00:27:00,660 And therefore, the Fourier transform of that 511 00:27:00,660 --> 00:27:03,330 is the convolution of a Gaussian with these two peaks. 512 00:27:06,440 --> 00:27:09,020 And there are many, many examples 513 00:27:09,020 --> 00:27:14,000 of interesting and useful functions in the time domain 514 00:27:14,000 --> 00:27:16,310 that you can intuitively understand 515 00:27:16,310 --> 00:27:21,920 what their Fourier transform is just by having this idea. 516 00:27:21,920 --> 00:27:23,356 It's very powerful. 517 00:27:23,356 --> 00:27:25,610 Here's another example. 518 00:27:25,610 --> 00:27:27,110 We're going to calculate the Fourier 519 00:27:27,110 --> 00:27:34,330 transform of this square windowed cosine function. 520 00:27:34,330 --> 00:27:40,130 So it's a product of the square pulse with this cosine 521 00:27:40,130 --> 00:27:41,120 to give this. 522 00:27:41,120 --> 00:27:43,278 So what is the Fourier transform of this. 523 00:27:43,278 --> 00:27:43,820 What is that? 524 00:27:46,470 --> 00:27:48,497 So what is the Fourier transform of that? 525 00:27:48,497 --> 00:27:49,720 AUDIENCE: The sinc function. 526 00:27:49,720 --> 00:27:51,220 MICHALE FEE: It's the sync function. 527 00:27:51,220 --> 00:27:54,310 It's that kind of wiggly, peaky thing. 528 00:27:54,310 --> 00:27:56,860 And the Fourier transform of that is just two peaks. 529 00:27:56,860 --> 00:28:02,370 And so the Fourier transform of this is just like two peaks-- 530 00:28:02,370 --> 00:28:05,190 yeah-- with wiggly stuff around them. 531 00:28:05,190 --> 00:28:07,630 That's exactly right. 532 00:28:07,630 --> 00:28:11,200 All right, any questions about that? 533 00:28:11,200 --> 00:28:12,005 OK. 534 00:28:12,005 --> 00:28:13,380 All right, change of topic, let's 535 00:28:13,380 --> 00:28:16,686 talk about Gaussian noise. 536 00:28:16,686 --> 00:28:20,640 The Fourier transform of noise and the power spectrum 537 00:28:20,640 --> 00:28:21,210 of noise. 538 00:28:21,210 --> 00:28:23,250 And we're going to eventually bring 539 00:28:23,250 --> 00:28:25,080 all these things back together. 540 00:28:25,080 --> 00:28:25,980 OK? 541 00:28:25,980 --> 00:28:28,890 All right, so what is Gaussian noise? 542 00:28:28,890 --> 00:28:33,360 So first of all, Gaussian noise is a signal 543 00:28:33,360 --> 00:28:38,280 in which the value at each time is randomly sampled 544 00:28:38,280 --> 00:28:39,630 from a Gaussian distribution. 545 00:28:39,630 --> 00:28:41,160 So you can do that in Matlab. 546 00:28:41,160 --> 00:28:43,140 That's a very simple function. 547 00:28:43,140 --> 00:28:45,600 This returns a vector of length N, 548 00:28:45,600 --> 00:28:51,580 sampled from a normal distribution, with variance 1. 549 00:28:51,580 --> 00:28:53,070 So here's what that sounds like. 550 00:28:58,854 --> 00:29:05,220 [STATIC NOISE] Sounds noisy, right? 551 00:29:05,220 --> 00:29:09,480 OK, I just wanted to show you what the autocorrelation 552 00:29:09,480 --> 00:29:12,430 function of this looks like, which I think we saw before. 553 00:29:12,430 --> 00:29:14,880 So if you look at the distribution of all 554 00:29:14,880 --> 00:29:17,950 the samples, it just gives you a distribution 555 00:29:17,950 --> 00:29:20,730 that it has the shape of a Gaussian. 556 00:29:20,730 --> 00:29:27,520 And the standard deviation of that Gaussian is 1. 557 00:29:27,520 --> 00:29:34,640 Now, what if you plot the correlation 558 00:29:34,640 --> 00:29:39,800 between the value of value of this function at time t 559 00:29:39,800 --> 00:29:43,310 and time t plus 1? 560 00:29:43,310 --> 00:29:45,440 Is there any relation between the value 561 00:29:45,440 --> 00:29:49,710 of this function at any time t and another time t plus 1? 562 00:29:49,710 --> 00:29:52,970 So they're completely uncorrelated with each other. 563 00:29:52,970 --> 00:29:56,000 The value of time t is uncorrelated with the value 564 00:29:56,000 --> 00:29:57,680 of time t plus 1. 565 00:29:57,680 --> 00:30:02,720 So there's zero correlations between neighboring samples. 566 00:30:02,720 --> 00:30:06,380 What about the correlation of the signal at time 567 00:30:06,380 --> 00:30:09,170 t with the signal at time t? 568 00:30:09,170 --> 00:30:12,110 Well, that's perfectly correlated, obviously. 569 00:30:12,110 --> 00:30:17,150 So we can plot the correlation of this function with itself 570 00:30:17,150 --> 00:30:18,400 at different time lags. 571 00:30:18,400 --> 00:30:21,240 Remember, that was the autocorrelation function. 572 00:30:21,240 --> 00:30:27,740 And if we do that, you get a 1 at 0 lag and 0 573 00:30:27,740 --> 00:30:29,840 at any other lag. 574 00:30:29,840 --> 00:30:32,990 So that's the autocorrelation function of Gaussian noise. 575 00:30:36,400 --> 00:30:40,310 All right, now, the Fourier transform of Gaussian noise 576 00:30:40,310 --> 00:30:44,100 is just Gaussian noise. 577 00:30:44,100 --> 00:30:49,940 It's another kind of interesting Fourier transform pair. 578 00:30:49,940 --> 00:30:52,020 And it's a Gaussian distribution. 579 00:30:52,020 --> 00:30:53,750 It's a Gaussian random distribution 580 00:30:53,750 --> 00:30:56,840 in both the real and the imaginary part. 581 00:30:56,840 --> 00:30:58,940 So you can see that the blue and red-- 582 00:30:58,940 --> 00:31:00,740 the red here is the imaginary part-- 583 00:31:00,740 --> 00:31:04,302 are both just Gaussian noise. 584 00:31:04,302 --> 00:31:04,802 OK? 585 00:31:08,570 --> 00:31:10,530 All right, now what is the power spectrum? 586 00:31:10,530 --> 00:31:13,008 So we can take this thing-- 587 00:31:13,008 --> 00:31:15,050 and, remember, when we plot the power [AUDIO OUT] 588 00:31:15,050 --> 00:31:18,110 just plot the square magnitude of just 589 00:31:18,110 --> 00:31:19,550 the positive frequencies. 590 00:31:19,550 --> 00:31:20,930 Why is that again? 591 00:31:20,930 --> 00:31:24,410 Why do we only have to plot the square magnitude 592 00:31:24,410 --> 00:31:26,786 of the positive frequencies? 593 00:31:26,786 --> 00:31:31,270 AUDIENCE: [INAUDIBLE] Gaussian, so they're all [INAUDIBLE] 594 00:31:31,270 --> 00:31:32,380 MICHALE FEE: Yep. 595 00:31:32,380 --> 00:31:39,310 So it turns out that the Fourier transform 596 00:31:39,310 --> 00:31:42,345 in a positive frequency is just the complex conjugate 597 00:31:42,345 --> 00:31:44,470 of the Fourier transform in the negative frequency. 598 00:31:44,470 --> 00:31:47,180 So the square magnitude is identical. 599 00:31:47,180 --> 00:31:49,390 So the power spectrum on this side 600 00:31:49,390 --> 00:31:51,370 is equal to the power spectrum on that side. 601 00:31:51,370 --> 00:31:55,030 So we just plot half of it. 602 00:31:55,030 --> 00:31:57,400 So that's what the power spectrum 603 00:31:57,400 --> 00:32:01,210 of this particular piece of signal looks like. 604 00:32:01,210 --> 00:32:05,980 The power spectrum of noise is very noisy. 605 00:32:05,980 --> 00:32:08,590 We're going to come back, and I'm 606 00:32:08,590 --> 00:32:12,050 going to show you that on average, 607 00:32:12,050 --> 00:32:17,860 if you take many different signals, many copies of this, 608 00:32:17,860 --> 00:32:20,210 and calculate the power spectrum and average them all 609 00:32:20,210 --> 00:32:22,480 altogether, it's going to be flat. 610 00:32:22,480 --> 00:32:25,970 But for any given piece of noisy signal, 611 00:32:25,970 --> 00:32:29,000 the power spectrum is very noisy. 612 00:32:29,000 --> 00:32:31,930 Any questions about that? 613 00:32:31,930 --> 00:32:33,580 OK. 614 00:32:33,580 --> 00:32:37,750 All right, so now let's turn to spectral estimation. 615 00:32:37,750 --> 00:32:42,040 How do we estimate the spectrum of a signal? 616 00:32:46,580 --> 00:32:50,630 So let's say you have a signal, S of t. 617 00:32:50,630 --> 00:32:55,340 And you have a bunch of short measurements of that signal. 618 00:32:55,340 --> 00:32:57,840 You have some signal, let's say, from the brain, 619 00:32:57,840 --> 00:33:04,040 like you record some local field potential or some ECG 620 00:33:04,040 --> 00:33:05,480 or something like that. 621 00:33:05,480 --> 00:33:09,243 And you want to find the spectrum of that. 622 00:33:09,243 --> 00:33:10,910 Let's say you're interested in measuring 623 00:33:10,910 --> 00:33:14,330 the theta rhythm or some alpha rhythm 624 00:33:14,330 --> 00:33:17,960 or some other periodic signal in the brain. 625 00:33:17,960 --> 00:33:20,000 What you could do is you could have 626 00:33:20,000 --> 00:33:24,035 a bunch of independent measurements of that signal. 627 00:33:24,035 --> 00:33:29,670 Let's in this case call them four trials, a bunch of trials. 628 00:33:29,670 --> 00:33:33,480 What you can do is calculate the power spectrum, 629 00:33:33,480 --> 00:33:37,230 just like [AUDIO OUT] for each of those signals. 630 00:33:37,230 --> 00:33:42,040 So this is a little sample y of t, y1 of t, y2 of t. 631 00:33:42,040 --> 00:33:44,930 You can calculate the square of magnitude 632 00:33:44,930 --> 00:33:47,910 of the Fourier transform of each one of those samples. 633 00:33:47,910 --> 00:33:50,960 And you can estimate the spectrum of those signals 634 00:33:50,960 --> 00:33:54,500 by just averaging together those separate, independent 635 00:33:54,500 --> 00:33:56,145 estimates. 636 00:33:56,145 --> 00:33:57,020 Does that make sense? 637 00:33:57,020 --> 00:33:59,870 So literally, we just do what we did here. 638 00:33:59,870 --> 00:34:01,760 We have a little bit of signal. 639 00:34:01,760 --> 00:34:04,700 We Fourier transform it, take the square magnitude. 640 00:34:04,700 --> 00:34:10,312 And now, you average together all of your different samples. 641 00:34:10,312 --> 00:34:13,290 Does that makes sense? 642 00:34:13,290 --> 00:34:17,179 That's the simplest form of spectral estimation. 643 00:34:17,179 --> 00:34:24,590 It's like if you want to estimate the average height 644 00:34:24,590 --> 00:34:26,090 of a population of people. 645 00:34:26,090 --> 00:34:28,670 You take a bunch of different measurements. 646 00:34:28,670 --> 00:34:29,503 You randomly sample. 647 00:34:29,503 --> 00:34:31,295 You take a bunch of different measurements. 648 00:34:31,295 --> 00:34:32,780 And you average them together. 649 00:34:32,780 --> 00:34:36,192 That's all we're doing here. 650 00:34:36,192 --> 00:34:36,692 OK? 651 00:34:41,290 --> 00:34:46,659 Now, you can apply that same principle to long signals. 652 00:34:46,659 --> 00:34:48,580 What you do is you just take that signal 653 00:34:48,580 --> 00:34:50,630 and you break it into short pieces. 654 00:34:53,440 --> 00:34:55,989 And you compute the power spectrum 655 00:34:55,989 --> 00:34:57,800 in each one of those windows. 656 00:34:57,800 --> 00:35:00,160 And again, you average them together. 657 00:35:00,160 --> 00:35:04,540 Now, extracting that little piece of signal 658 00:35:04,540 --> 00:35:07,870 from this longer signal is essentially the same 659 00:35:07,870 --> 00:35:13,690 as multiplying that long signal by a square pulse. 660 00:35:13,690 --> 00:35:17,530 0 everywhere, but 1 in here, 1 here. 661 00:35:17,530 --> 00:35:19,090 0 everywhere else. 662 00:35:19,090 --> 00:35:19,590 Right? 663 00:35:22,860 --> 00:35:25,560 So that process of taking a long signal 664 00:35:25,560 --> 00:35:29,200 and extracting out one piece of it has a name. 665 00:35:29,200 --> 00:35:30,180 It's called windowing. 666 00:35:32,830 --> 00:35:37,425 Sort of like you're looking at a scene through this window, 667 00:35:37,425 --> 00:35:38,550 and that's all you can see. 668 00:35:44,760 --> 00:35:48,300 OK, so one way to estimate the spectrum of this signal 669 00:35:48,300 --> 00:35:51,990 is to take the signal in this window, 670 00:35:51,990 --> 00:35:57,150 compute the FFT of that, take this power spectrum. 671 00:35:57,150 --> 00:36:02,050 And then apply this window to the next piece. 672 00:36:02,050 --> 00:36:05,510 Apply this window to the next piece and compute the spectrum 673 00:36:05,510 --> 00:36:07,340 and average them all altogether. 674 00:36:07,340 --> 00:36:10,010 What's the problem with that? 675 00:36:10,010 --> 00:36:11,920 Why might that be a bad idea? 676 00:36:16,087 --> 00:36:17,480 Yeah. 677 00:36:17,480 --> 00:36:20,670 AUDIENCE: Could we [INAUDIBLE]. 678 00:36:20,670 --> 00:36:22,040 MICHALE FEE: Good. 679 00:36:22,040 --> 00:36:24,830 That's a very good example. 680 00:36:24,830 --> 00:36:27,440 But there's sort of a general principle 681 00:36:27,440 --> 00:36:33,500 that we just learned that you can apply to this problem. 682 00:36:33,500 --> 00:36:36,680 What happens to the Fourier transform of the signal 683 00:36:36,680 --> 00:36:41,696 when we multiply it by this square pulse? 684 00:36:41,696 --> 00:36:43,630 AUDIENCE: Convolving. 685 00:36:43,630 --> 00:36:48,320 MICHALE FEE: We're convolving the spectrum of the signal 686 00:36:48,320 --> 00:36:49,880 with a sinc function. 687 00:36:49,880 --> 00:36:51,860 And the sinc function is really ugly, right? 688 00:36:51,860 --> 00:36:53,960 It's got lots of wiggles. 689 00:36:53,960 --> 00:36:57,650 And so it turns out this process of windowing 690 00:36:57,650 --> 00:37:00,950 a piece of data with this square pulse 691 00:37:00,950 --> 00:37:03,020 actually does really horrible things 692 00:37:03,020 --> 00:37:05,780 to our spectral estimate. 693 00:37:05,780 --> 00:37:08,450 And we're going to spend a lot of time 694 00:37:08,450 --> 00:37:12,410 in the next lecture addressing how 695 00:37:12,410 --> 00:37:15,320 you solve that problem in a principled way 696 00:37:15,320 --> 00:37:17,870 and make a good estimate of the signal 697 00:37:17,870 --> 00:37:20,330 by breaking it up into little pieces. 698 00:37:20,330 --> 00:37:23,750 But instead of just taking a square window 699 00:37:23,750 --> 00:37:26,430 we do something called tapering. 700 00:37:26,430 --> 00:37:31,580 So instead of multiplying this signal by square pulses, 701 00:37:31,580 --> 00:37:33,860 we sample the signal by applying it 702 00:37:33,860 --> 00:37:37,640 by little things that look like little smooth functions, 703 00:37:37,640 --> 00:37:40,750 like maybe a Gaussian, or other functions that we'll talk about 704 00:37:40,750 --> 00:37:43,780 do an even better job. 705 00:37:43,780 --> 00:37:45,130 OK? 706 00:37:45,130 --> 00:37:47,690 All right. 707 00:37:47,690 --> 00:37:51,910 OK, so that process is called tapering, multiplying 708 00:37:51,910 --> 00:37:53,920 your data by a little [AUDIO OUT] paper 709 00:37:53,920 --> 00:37:57,780 that's smooth, unlike a square window. 710 00:37:57,780 --> 00:38:02,430 Computing spectral estimates from each one of those windowed 711 00:38:02,430 --> 00:38:06,840 and tapered pieces of data gives you a very good estimate 712 00:38:06,840 --> 00:38:07,530 of the spectra. 713 00:38:07,530 --> 00:38:09,450 And we're going to come back to that, 714 00:38:09,450 --> 00:38:12,670 how to really do that right, on Thursday. 715 00:38:12,670 --> 00:38:13,170 OK? 716 00:38:17,280 --> 00:38:22,470 All right, let me point out why this method 717 00:38:22,470 --> 00:38:24,780 of spectral estimation is very powerful. 718 00:38:24,780 --> 00:38:28,770 So, remember, we talked about how you can see-- 719 00:38:28,770 --> 00:38:32,590 remember, we talked about if you have a noisy signal that 720 00:38:32,590 --> 00:38:35,310 has a little bit of underlying sine wave in it, 721 00:38:35,310 --> 00:38:38,490 we talked about in class, if you take 722 00:38:38,490 --> 00:38:40,300 the autocorrelation of that function, 723 00:38:40,300 --> 00:38:43,410 you get a delta function and then some little wiggles. 724 00:38:43,410 --> 00:38:46,800 So there are ways of pulling periodic signals, 725 00:38:46,800 --> 00:38:49,260 periodic structure out of noisy signals. 726 00:38:49,260 --> 00:38:51,723 But it turns out that this method 727 00:38:51,723 --> 00:38:53,140 of spectral estimation [AUDIO OUT] 728 00:38:53,140 --> 00:38:55,800 did the most powerful way to do it. 729 00:38:55,800 --> 00:38:57,840 I'm just going to show you one example. 730 00:38:57,840 --> 00:39:01,740 This blue function here is noise, 731 00:39:01,740 --> 00:39:06,720 plus a little bit of a sine wave at, I think it's 10 hertz. 732 00:39:06,720 --> 00:39:08,090 OK, yeah. 733 00:39:08,090 --> 00:39:09,840 Anyway, I didn't write down the frequency. 734 00:39:09,840 --> 00:39:14,280 But the blue function here is noise plus the red function. 735 00:39:14,280 --> 00:39:17,190 So you can see the red function is small. 736 00:39:17,190 --> 00:39:20,440 And it's buried in the noise, so that you can't see it. 737 00:39:20,440 --> 00:39:23,070 But when you do this process of spectral estimation 738 00:39:23,070 --> 00:39:24,780 that we're learning about, you can 739 00:39:24,780 --> 00:39:29,800 see that that signal buried in that noise 740 00:39:29,800 --> 00:39:33,740 is now very easily visible. 741 00:39:33,740 --> 00:39:39,010 So using these methods, you can pull tiny signals out of noise 742 00:39:39,010 --> 00:39:42,280 at a very bad signal to noise ratio, 743 00:39:42,280 --> 00:39:45,500 where the signal is really buried in the noise. 744 00:39:45,500 --> 00:39:46,820 So it's a very powerful method. 745 00:39:46,820 --> 00:39:48,700 And we're going to spend more time talking 746 00:39:48,700 --> 00:39:50,500 about how to do that properly. 747 00:39:58,630 --> 00:40:01,540 All right, so let me spend a little bit more time talking 748 00:40:01,540 --> 00:40:04,720 about the power spectrum of noise, 749 00:40:04,720 --> 00:40:10,250 so that we have a better sense of what that looks like. 750 00:40:10,250 --> 00:40:12,970 So remember, I told you if you take 751 00:40:12,970 --> 00:40:16,270 a sample of noise like this and you estimate the spectrum 752 00:40:16,270 --> 00:40:19,480 of it, you compute the power spectrum of one sample 753 00:40:19,480 --> 00:40:21,250 of noise, it's extremely noisy. 754 00:40:24,550 --> 00:40:26,250 Let's see, I'm just going to remind you 755 00:40:26,250 --> 00:40:27,140 what that looks like. 756 00:40:30,320 --> 00:40:35,110 That's the power spectrum of one sample of noise. 757 00:40:35,110 --> 00:40:38,890 In order to estimate what the spectrum of noise looks like, 758 00:40:38,890 --> 00:40:41,720 you have to take many examples of that 759 00:40:41,720 --> 00:40:43,640 and average them together. 760 00:40:43,640 --> 00:40:45,880 And when you do that, what you find 761 00:40:45,880 --> 00:40:50,060 is that the power spectrum of noise is a constant. 762 00:40:50,060 --> 00:40:50,560 It's flat. 763 00:40:50,560 --> 00:40:51,685 [AUDIO OUT] Gaussian noise. 764 00:40:55,020 --> 00:41:00,970 The power spectrum, really, you should think about it properly 765 00:41:00,970 --> 00:41:03,010 as a power spectral density. 766 00:41:03,010 --> 00:41:07,300 There is a certain amount of power at different frequencies 767 00:41:07,300 --> 00:41:08,440 in this signal. 768 00:41:08,440 --> 00:41:11,110 So there is some power at low frequency, 769 00:41:11,110 --> 00:41:12,880 some power at intermediate frequencies, 770 00:41:12,880 --> 00:41:14,450 some power at high frequencies. 771 00:41:14,450 --> 00:41:18,730 And for Gaussian noise, that power spectral density is flat. 772 00:41:18,730 --> 00:41:21,490 It's constant as a function of frequency. 773 00:41:21,490 --> 00:41:21,990 OK? 774 00:41:25,750 --> 00:41:32,560 And the units here have units of variance per unit frequency-- 775 00:41:32,560 --> 00:41:34,680 variance per frequency. 776 00:41:34,680 --> 00:41:36,270 OK? 777 00:41:36,270 --> 00:41:38,513 Or if it were an electrical signal 778 00:41:38,513 --> 00:41:39,930 going through a resistor, it would 779 00:41:39,930 --> 00:41:43,560 be power per unit frequency. 780 00:41:43,560 --> 00:41:48,940 So you can see that here the value here is 0.002. 781 00:41:48,940 --> 00:41:51,900 The bandwidth of this signal is 500 hertz. 782 00:41:51,900 --> 00:41:54,570 And so the variance is the variance 783 00:41:54,570 --> 00:41:58,420 per unit per unit frequency times the bandwidth. 784 00:41:58,420 --> 00:41:59,500 And that's 1. 785 00:41:59,500 --> 00:42:02,670 And we started with a Gaussian noise 786 00:42:02,670 --> 00:42:06,990 that has variance 1, that when we calculate the power 787 00:42:06,990 --> 00:42:09,840 spectrum of that we can correctly read out 788 00:42:09,840 --> 00:42:13,740 from the power spectrum how much variance there is per unit 789 00:42:13,740 --> 00:42:15,660 frequency in the signal. 790 00:42:15,660 --> 00:42:16,350 OK? 791 00:42:16,350 --> 00:42:18,660 All right, it's kind of a subtle point. 792 00:42:18,660 --> 00:42:21,930 I actually don't expect you to know this. 793 00:42:21,930 --> 00:42:24,900 I just wanted you to see it and hear it. 794 00:42:24,900 --> 00:42:27,360 So you know formally what it is that you're 795 00:42:27,360 --> 00:42:30,030 looking at when you look at a spectral estimate 796 00:42:30,030 --> 00:42:31,020 of a noisy signal. 797 00:42:33,850 --> 00:42:36,390 All right, let's talk about filtering in the frequency 798 00:42:36,390 --> 00:42:36,890 domain. 799 00:42:36,890 --> 00:42:39,790 So remember, we learned how to smooth a signal, 800 00:42:39,790 --> 00:42:43,360 how to filter a signal, either high pass or low pass, 801 00:42:43,360 --> 00:42:46,840 by convolving a signal with a kernel. 802 00:42:46,840 --> 00:42:52,990 So you remember that the kernel for a low pass 803 00:42:52,990 --> 00:42:54,250 was something like this. 804 00:42:56,880 --> 00:43:01,930 So when you convolve, that's the kernel for a low pass. 805 00:43:05,010 --> 00:43:08,955 And for a high pass, anybody remember what that looks like? 806 00:43:08,955 --> 00:43:12,912 AUDIENCE: [INAUDIBLE] 807 00:43:12,912 --> 00:43:13,620 MICHALE FEE: Yep. 808 00:43:13,620 --> 00:43:17,260 So-- sorry, I should be a little more careful here not to mix up 809 00:43:17,260 --> 00:43:18,610 my axes with-- 810 00:43:21,580 --> 00:43:23,570 I'm going to remove that. 811 00:43:23,570 --> 00:43:26,040 So that's the kernel for a low-pass filter. 812 00:43:26,040 --> 00:43:27,590 The kernel for a high-pass filter 813 00:43:27,590 --> 00:43:32,120 is a delta function that reproduces the function. 814 00:43:32,120 --> 00:43:37,400 And then you subtract off a low-pass filtered version 815 00:43:37,400 --> 00:43:38,330 of the signal. 816 00:43:38,330 --> 00:43:39,110 OK? 817 00:43:39,110 --> 00:43:43,730 So that's the kernel for a high pass. 818 00:43:46,600 --> 00:43:49,150 OK, so this was how you filter a signal 819 00:43:49,150 --> 00:43:54,910 by convolving your signal with a function, with a linear kernel. 820 00:43:54,910 --> 00:43:58,030 We're going to talk now about how you do filtering 821 00:43:58,030 --> 00:44:00,670 in the frequency domain. 822 00:44:00,670 --> 00:44:03,160 So if filtering in the time domain 823 00:44:03,160 --> 00:44:08,250 is convolving your [AUDIO OUT] with a function, 824 00:44:08,250 --> 00:44:12,214 what is filtering in the frequency domain going to be? 825 00:44:12,214 --> 00:44:13,090 AUDIENCE: [INAUDIBLE] 826 00:44:13,090 --> 00:44:13,882 MICHALE FEE: Right. 827 00:44:13,882 --> 00:44:16,630 It's going to be multiplying the Fourier transform 828 00:44:16,630 --> 00:44:21,163 of your signal times what? 829 00:44:21,163 --> 00:44:23,010 AUDIENCE: The Fourier transform [INAUDIBLE] 830 00:44:23,010 --> 00:44:25,440 MICHALE FEE: The Fourier transform of things like that. 831 00:44:28,050 --> 00:44:31,210 All right, so let's do that. 832 00:44:31,210 --> 00:44:33,080 So this is what we just talked about. 833 00:44:33,080 --> 00:44:34,940 We introduced the idea before. 834 00:44:34,940 --> 00:44:37,220 This was actually a neural signal 835 00:44:37,220 --> 00:44:40,100 that has spikes up here and local field potentials 836 00:44:40,100 --> 00:44:41,030 down here. 837 00:44:41,030 --> 00:44:43,400 And we can extract the local field potentials 838 00:44:43,400 --> 00:44:47,570 by smoothing this [AUDIO OUT] by low pass filtering it, 839 00:44:47,570 --> 00:44:50,180 by convolving it with this kernel here. 840 00:44:52,910 --> 00:44:55,450 So this is what we just talked about. 841 00:44:55,450 --> 00:44:57,750 So if filtering in the time domain 842 00:44:57,750 --> 00:45:00,300 is convolving your data with a signal, 843 00:45:00,300 --> 00:45:02,580 then filtering in the frequency domain 844 00:45:02,580 --> 00:45:05,340 is multiplying the Fourier transform of a [AUDIO OUT] 845 00:45:05,340 --> 00:45:08,250 times the Fourier transform of the kernel. 846 00:45:08,250 --> 00:45:12,030 And you can see that what this does to the power spectrum 847 00:45:12,030 --> 00:45:14,010 is just what you would expect. 848 00:45:14,010 --> 00:45:16,850 The power spectrum of the filtered signal 849 00:45:16,850 --> 00:45:20,820 is just the power spectrum of your original signal 850 00:45:20,820 --> 00:45:24,030 times the power spectrum of the kernel. 851 00:45:27,160 --> 00:45:30,350 All right, so here's an example. 852 00:45:30,350 --> 00:45:35,110 So in blue is the original Gaussian noise. 853 00:45:35,110 --> 00:45:39,960 In green is the kernel that I'm smoothing it by, 854 00:45:39,960 --> 00:45:41,070 filtering it by. 855 00:45:41,070 --> 00:45:45,600 Convolving the blue with the green gives you the red signal. 856 00:45:45,600 --> 00:45:47,370 What kind of filter is that called again? 857 00:45:52,790 --> 00:45:53,888 High pass or low pass? 858 00:45:53,888 --> 00:45:54,680 AUDIENCE: Low pass. 859 00:45:54,680 --> 00:45:56,060 MICHALE FEE: Low pass, good. 860 00:45:56,060 --> 00:46:00,720 All right, so let me play you what those sound like. 861 00:46:00,720 --> 00:46:03,364 So here's the original Gaussian noise. 862 00:46:03,364 --> 00:46:09,560 [STATIC] Good. 863 00:46:09,560 --> 00:46:11,570 And here's the low pass Gaussian noise. 864 00:46:14,474 --> 00:46:21,560 [LOWER STATIC] It got rid of about the high frequency 865 00:46:21,560 --> 00:46:22,580 parts of the noise. 866 00:46:27,240 --> 00:46:34,400 OK, so here's the power spectrum of the original signal in blue. 867 00:46:34,400 --> 00:46:37,940 In order to get the power spectrum of the filtered signal 868 00:46:37,940 --> 00:46:43,700 in red, we're going to multiply that by the magnitude squared 869 00:46:43,700 --> 00:46:45,530 Fourier transform of this. 870 00:46:45,530 --> 00:46:46,980 What do you think that looks like? 871 00:46:46,980 --> 00:46:49,850 So this is a little Gaussian filter in time. 872 00:46:49,850 --> 00:46:52,620 What is the Fourier transform of that going to look like? 873 00:46:52,620 --> 00:46:54,000 AUDIENCE: [INAUDIBLE] 874 00:46:54,000 --> 00:46:56,110 MICHALE FEE: The Fourier transform of a Gaussian 875 00:46:56,110 --> 00:46:59,950 is a Gaussian. 876 00:46:59,950 --> 00:47:05,790 So the power spectrum of that signal 877 00:47:05,790 --> 00:47:07,240 is going to just be a Gaussian. 878 00:47:07,240 --> 00:47:09,090 Now, how would I plot it? 879 00:47:09,090 --> 00:47:10,110 It's peaked where? 880 00:47:13,730 --> 00:47:18,450 The Fourier transform of a Gaussian is peaked at 0. 881 00:47:18,450 --> 00:47:21,680 So it's going to be a Gaussian here centered at 0. 882 00:47:21,680 --> 00:47:23,740 We're only plotting the positive frequencies. 883 00:47:23,740 --> 00:47:25,160 So this, we're ignoring. 884 00:47:25,160 --> 00:47:28,940 And it's going to be like that, right? 885 00:47:28,940 --> 00:47:33,020 So that's the Fourier transform, squared magnitude Fourier 886 00:47:33,020 --> 00:47:34,530 transform of that Gaussian. 887 00:47:34,530 --> 00:47:37,480 It's just another Gaussian. 888 00:47:37,480 --> 00:47:41,620 And now if we multiply this power spectrum times that power 889 00:47:41,620 --> 00:47:44,570 spectrum, we get the power spectrum 890 00:47:44,570 --> 00:47:46,210 of our filtered signal. 891 00:47:46,210 --> 00:47:47,420 Does that makes sense? 892 00:47:51,730 --> 00:47:58,990 So convolving our original blue signal with this green Gaussian 893 00:47:58,990 --> 00:48:01,870 kernel smooths the signal. 894 00:48:01,870 --> 00:48:04,300 It gets rid of high frequencies. 895 00:48:04,300 --> 00:48:07,810 In the frequency domain, that's like multiplying 896 00:48:07,810 --> 00:48:12,910 the spectrum of the blue signal by a function that's 897 00:48:12,910 --> 00:48:17,250 0 at high frequencies and 1 at low frequencies. 898 00:48:20,040 --> 00:48:21,860 Does that makes sense? 899 00:48:21,860 --> 00:48:25,490 So filtering in the frequency domain, low filtering 900 00:48:25,490 --> 00:48:28,970 in the frequency domain, means multiplying the power spectrum 901 00:48:28,970 --> 00:48:33,920 of your signal by a function that's low at high frequencies 902 00:48:33,920 --> 00:48:35,300 and big at low frequencies. 903 00:48:35,300 --> 00:48:39,110 So it passes the frequencies and suppresses 904 00:48:39,110 --> 00:48:40,580 the high frequencies. 905 00:48:45,380 --> 00:48:46,470 It's that simple. 906 00:48:51,400 --> 00:48:52,830 Any questions about that? 907 00:48:55,900 --> 00:48:57,380 Well, yes-- 908 00:48:57,380 --> 00:48:59,626 AUDIENCE: So why is it that like-- 909 00:48:59,626 --> 00:49:01,270 you need to like-- 910 00:49:01,270 --> 00:49:04,555 of I guess when you multiply in the frequency, 911 00:49:04,555 --> 00:49:08,060 could you theoretically multiply by anything 912 00:49:08,060 --> 00:49:11,816 and that would correspond to some other type of filter. 913 00:49:11,816 --> 00:49:16,361 So why don't we just like throw away high frequencies? 914 00:49:16,361 --> 00:49:21,340 Or something like multiply by a square in the frequency domain 915 00:49:21,340 --> 00:49:24,560 and correspond to some different filter we don't know. 916 00:49:24,560 --> 00:49:25,430 MICHALE FEE: Yeah. 917 00:49:25,430 --> 00:49:26,390 You can do that. 918 00:49:26,390 --> 00:49:32,440 You can take a signal like this, Fourier transform it, multiply 919 00:49:32,440 --> 00:49:38,860 it by a square window to suppress high frequencies. 920 00:49:38,860 --> 00:49:42,000 What is that equivalent to? 921 00:49:42,000 --> 00:49:45,570 What would be the corresponding temporal kernel 922 00:49:45,570 --> 00:49:47,275 that that would correspond to? 923 00:49:47,275 --> 00:49:48,700 AUDIENCE: [INAUDIBLE] 924 00:49:48,700 --> 00:49:49,470 MICHALE FEE: Good. 925 00:49:49,470 --> 00:49:55,320 It would be convulsing your function with a sinc function. 926 00:49:55,320 --> 00:49:57,195 It turns out that's-- 927 00:50:03,320 --> 00:50:08,950 the reason you wouldn't normally do that 928 00:50:08,950 --> 00:50:12,940 is that it mixes the signal across all time. 929 00:50:12,940 --> 00:50:16,030 The sinc function goes on to infinity. 930 00:50:16,030 --> 00:50:18,940 So the nice thing about this is when you smooth a signal 931 00:50:18,940 --> 00:50:26,050 with a Gaussian, you're not adding some of the signal here 932 00:50:26,050 --> 00:50:27,040 that were over here. 933 00:50:27,040 --> 00:50:28,420 Does that makes sense? 934 00:50:28,420 --> 00:50:31,360 Convolving with a sinc function kind of mixes things in time. 935 00:50:35,230 --> 00:50:38,880 So normally you would smooth by functions 936 00:50:38,880 --> 00:50:43,770 that are kind of local in time, local in frequency, 937 00:50:43,770 --> 00:50:47,770 but not having sharp edges. 938 00:50:47,770 --> 00:50:48,710 Does that makes sense? 939 00:50:48,710 --> 00:50:53,890 So we're going to talk about how to smooth things in frequency 940 00:50:53,890 --> 00:51:00,820 with signals with kernels that are optimal for that job. 941 00:51:00,820 --> 00:51:03,990 That's Thursday. 942 00:51:03,990 --> 00:51:05,970 What would a high-pass filter look 943 00:51:05,970 --> 00:51:07,540 like in the frequency domain? 944 00:51:15,470 --> 00:51:21,540 So high-pass filter would pass high frequencies 945 00:51:21,540 --> 00:51:25,533 and suppress low frequencies. 946 00:51:25,533 --> 00:51:27,388 Right? 947 00:51:27,388 --> 00:51:29,680 You've probably not heard of it, but, what would a band 948 00:51:29,680 --> 00:51:32,450 pass filter look like? 949 00:51:32,450 --> 00:51:34,370 It would just pass a band. 950 00:51:34,370 --> 00:51:35,890 So it'd be 0 here. 951 00:51:35,890 --> 00:51:37,710 It would be big somewhere in the middle 952 00:51:37,710 --> 00:51:42,020 and then go to 0 at higher frequencies. 953 00:51:42,020 --> 00:51:43,630 OK? 954 00:51:43,630 --> 00:51:45,268 Does that makes sense? 955 00:51:45,268 --> 00:51:46,310 Any questions about that? 956 00:51:49,210 --> 00:51:50,030 OK. 957 00:51:50,030 --> 00:51:50,530 Good. 958 00:51:54,710 --> 00:52:00,160 If we plot this on a log plot in decibels, 959 00:52:00,160 --> 00:52:03,715 you can see that on a log plot, a Gaussian, 960 00:52:03,715 --> 00:52:09,000 which is e to [AUDIO OUT] like f squared. 961 00:52:09,000 --> 00:52:11,830 On a log plot, that's minus f squared. 962 00:52:11,830 --> 00:52:12,330 Right? 963 00:52:12,330 --> 00:52:14,100 That's why on a log plot this would 964 00:52:14,100 --> 00:52:17,050 look like an inverted parabola. 965 00:52:17,050 --> 00:52:23,160 So that's the same plot here, but plotted on a log scale. 966 00:52:27,890 --> 00:52:28,990 Any questions about that? 967 00:52:35,320 --> 00:52:38,950 I want to tell you about a cool little theorem called 968 00:52:38,950 --> 00:52:43,360 the Wiener-Khinchin theorem that relates the power 969 00:52:43,360 --> 00:52:50,500 spectrum of a signal with the autocorrelation of a signal. 970 00:52:50,500 --> 00:52:59,780 So in blue, that's our original Gaussian noise. 971 00:52:59,780 --> 00:53:03,230 In red is our smooth Gaussian noise. 972 00:53:03,230 --> 00:53:07,610 If you look at the correlation of neighboring time 973 00:53:07,610 --> 00:53:09,140 points in the blue signal, you can 974 00:53:09,140 --> 00:53:12,030 see they're completely uncorrelated with each other. 975 00:53:12,030 --> 00:53:15,500 But what about neighboring time points on the smooth signal? 976 00:53:15,500 --> 00:53:17,000 Are they correlated with each other? 977 00:53:23,266 --> 00:53:28,820 If we look at for the red signal, y of i 978 00:53:28,820 --> 00:53:32,180 and y of i plus 1, what does that look 979 00:53:32,180 --> 00:53:34,523 like for the red signal? 980 00:53:34,523 --> 00:53:36,440 They become correlated with each other, right? 981 00:53:36,440 --> 00:53:41,660 Because each value of the smooth signal 982 00:53:41,660 --> 00:53:46,340 is some sum over the blue points. 983 00:53:46,340 --> 00:53:49,740 So neighboring points here will be similar to each other. 984 00:53:49,740 --> 00:53:52,040 That's what smoothness means. 985 00:53:52,040 --> 00:53:56,160 Neighboring time points are close to each other. 986 00:53:56,160 --> 00:53:58,580 So if you look at the correlation of neighboring time 987 00:53:58,580 --> 00:54:02,400 points in the smooth signal, it looks like this. 988 00:54:02,400 --> 00:54:04,010 It has a strong correlation. 989 00:54:06,530 --> 00:54:08,270 So if you look at the autocorrelation 990 00:54:08,270 --> 00:54:12,500 of the original Gaussian noise, it 991 00:54:12,500 --> 00:54:15,530 has a delta function at zero. 992 00:54:15,530 --> 00:54:19,370 The autocorrelation of the smoothed function 993 00:54:19,370 --> 00:54:21,440 has some width to it. 994 00:54:21,440 --> 00:54:23,450 And the width to that autocorrelation function 995 00:54:23,450 --> 00:54:27,080 tells you the time [AUDIO OUT] this signal was smoothed. 996 00:54:27,080 --> 00:54:27,980 Right? 997 00:54:27,980 --> 00:54:29,630 OK. 998 00:54:29,630 --> 00:54:32,370 Now, how does that relate to the power spectrum? 999 00:54:32,370 --> 00:54:36,420 So it turns out that the power spectrum 1000 00:54:36,420 --> 00:54:40,160 of a signal, the magnitude squared of the Fourier 1001 00:54:40,160 --> 00:54:43,270 transform, the power spectrum of the signal 1002 00:54:43,270 --> 00:54:48,920 is just the Fourier transform of the autocorrelation. 1003 00:54:48,920 --> 00:54:52,930 So what's the Fourier transform of a delta function? 1004 00:54:52,930 --> 00:54:55,654 Anybody remember that? 1005 00:54:55,654 --> 00:54:57,577 AUDIENCE: Constant. 1006 00:54:57,577 --> 00:54:58,785 MICHALE FEE: It's a constant. 1007 00:55:07,340 --> 00:55:10,100 And how about our smoothed? 1008 00:55:10,100 --> 00:55:14,120 Our smooth signal has a power spectrum 1009 00:55:14,120 --> 00:55:16,970 that's a Gaussian in this case. 1010 00:55:16,970 --> 00:55:20,268 What's the transform of a Gaussian? 1011 00:55:20,268 --> 00:55:25,702 AUDIENCE: [INAUDIBLE] 1012 00:55:25,702 --> 00:55:26,700 MICHALE FEE: OK. 1013 00:55:26,700 --> 00:55:32,190 So if you have a signal that you have some sense of what 1014 00:55:32,190 --> 00:55:34,410 the power spectrum is you immediately 1015 00:55:34,410 --> 00:55:35,880 know what the autocorrelation is. 1016 00:55:35,880 --> 00:55:40,740 You just Fourier transform that and get the autocorrelation. 1017 00:55:40,740 --> 00:55:45,108 What's the width of this in time? 1018 00:55:45,108 --> 00:55:46,400 How would I get that from here? 1019 00:55:56,530 --> 00:55:59,980 How are the width in time and frequency related to each other 1020 00:55:59,980 --> 00:56:00,480 for-- 1021 00:56:00,480 --> 00:56:01,120 AUDIENCE: [INAUDIBLE] 1022 00:56:01,120 --> 00:56:01,912 MICHALE FEE: Right. 1023 00:56:01,912 --> 00:56:03,790 The width of this in time is just 1 1024 00:56:03,790 --> 00:56:05,290 over the width of [AUDIO OUT] So you 1025 00:56:05,290 --> 00:56:08,610 have to take the full width. 1026 00:56:08,610 --> 00:56:10,450 Does that makes sense? 1027 00:56:10,450 --> 00:56:11,610 OK. 1028 00:56:11,610 --> 00:56:13,280 Wiener-Khinchin theorem, very cool. 1029 00:56:23,400 --> 00:56:28,850 All right, let's talk about the Shannon-Nyquist theorem. 1030 00:56:28,850 --> 00:56:33,720 Anybody heard of the Nyquist limit? 1031 00:56:33,720 --> 00:56:34,770 Anybody heard of this? 1032 00:56:38,150 --> 00:56:42,950 All right, so it's a very important theorem. 1033 00:56:42,950 --> 00:56:47,030 Basically anybody who's acquiring signals in the lab 1034 00:56:47,030 --> 00:56:49,760 needs to know the Shannon-Nyquist theorem. 1035 00:56:49,760 --> 00:56:52,570 It's very important. 1036 00:56:52,570 --> 00:56:58,180 All right, so remember that when we 1037 00:56:58,180 --> 00:57:01,120 have discrete Fourier transforms, fast Fourier 1038 00:57:01,120 --> 00:57:09,080 transforms, our frequencies are discretized and so is our time. 1039 00:57:09,080 --> 00:57:13,040 But the discretization in frequency 1040 00:57:13,040 --> 00:57:17,720 means that the function is periodic. 1041 00:57:17,720 --> 00:57:25,110 Any signal that has discrete components and frequencies 1042 00:57:25,110 --> 00:57:26,460 is periodic in time. 1043 00:57:26,460 --> 00:57:28,590 Remember, we started with Fourier series. 1044 00:57:28,590 --> 00:57:31,770 And we talked about how if you have a signal that's 1045 00:57:31,770 --> 00:57:34,320 periodic in time, that you can write it down 1046 00:57:34,320 --> 00:57:38,597 as a set of frequencies that are integer multiples 1047 00:57:38,597 --> 00:57:39,180 of each other. 1048 00:57:41,790 --> 00:57:48,030 Now, in these signals, time is sampled discretely 1049 00:57:48,030 --> 00:57:49,540 at regular time intervals. 1050 00:57:49,540 --> 00:57:53,400 So what does that tell us about the spectrum, the Fourier 1051 00:57:53,400 --> 00:57:54,000 transform? 1052 00:57:58,750 --> 00:58:00,180 AUDIENCE: It's periodic. 1053 00:58:00,180 --> 00:58:02,000 MICHALE FEE: It's also periodic. 1054 00:58:02,000 --> 00:58:09,560 OK, so discretely sampled in frequency at regular intervals 1055 00:58:09,560 --> 00:58:13,230 means that the signal is periodic in time. 1056 00:58:13,230 --> 00:58:17,720 Discretely sampled in time means that the Fourier transform 1057 00:58:17,720 --> 00:58:20,610 is periodic. 1058 00:58:20,610 --> 00:58:22,430 Now, we don't usually think about this. 1059 00:58:22,430 --> 00:58:26,470 We've been taking these signals, sines and cosines 1060 00:58:26,470 --> 00:58:29,290 and square pulses and Gaussian things, 1061 00:58:29,290 --> 00:58:31,750 and I've been showing you discretely sampled 1062 00:58:31,750 --> 00:58:34,430 versions of those signals. 1063 00:58:34,430 --> 00:58:36,430 And I've been showing you the Fourier transforms 1064 00:58:36,430 --> 00:58:37,750 of those signals. 1065 00:58:37,750 --> 00:58:42,800 But I've only been showing you this little part of it. 1066 00:58:42,800 --> 00:58:47,890 In fact, really be thinking that those discreetly sampled 1067 00:58:47,890 --> 00:58:52,520 signals have a Fourier transform that's actually periodic. 1068 00:58:52,520 --> 00:58:59,970 There's another copy of that spectrum sitting up here 1069 00:58:59,970 --> 00:59:05,080 at 1 over the sampling rate and another copy sitting up here. 1070 00:59:05,080 --> 00:59:07,710 Remember, this is like a train of delta functions. 1071 00:59:07,710 --> 00:59:09,990 The Fourier transform of that is like another train 1072 00:59:09,990 --> 00:59:13,360 of delta functions. 1073 00:59:13,360 --> 00:59:17,530 So there are copies of this spectrum spaced every 1 1074 00:59:17,530 --> 00:59:19,670 over delta t. 1075 00:59:19,670 --> 00:59:22,570 It's kind of a strange concept. 1076 00:59:30,500 --> 00:59:32,960 So the separation between those copies 1077 00:59:32,960 --> 00:59:35,450 of the spectra in the frequency domain 1078 00:59:35,450 --> 00:59:40,910 are given by 1 over the sampling rate. 1079 00:59:40,910 --> 00:59:42,410 Any questions about that? 1080 00:59:42,410 --> 00:59:44,470 It's a little strange. 1081 00:59:44,470 --> 00:59:45,940 But we'll push on because I think 1082 00:59:45,940 --> 00:59:47,107 it's going to be more clear. 1083 00:59:50,400 --> 00:59:56,780 So what this says is that if you want to properly sample 1084 00:59:56,780 --> 01:00:05,990 this signal in time, you need these [AUDIO OUT] copies 1085 01:00:05,990 --> 01:00:09,290 of its spectrum to be far away so they don't interfere 1086 01:00:09,290 --> 01:00:10,910 with each other. 1087 01:00:10,910 --> 01:00:18,410 So what that means is that you need the sampling rate 1088 01:00:18,410 --> 01:00:19,880 to be high enough-- 1089 01:00:19,880 --> 01:00:24,545 the higher the sampling rate is, the further these spectra 1090 01:00:24,545 --> 01:00:26,570 are in time. 1091 01:00:26,570 --> 01:00:30,320 Delta t is very small, which means 1 over delta t 1092 01:00:30,320 --> 01:00:33,150 is very big. 1093 01:00:33,150 --> 01:00:35,070 The sampling rate needs to be greater 1094 01:00:35,070 --> 01:00:40,210 than twice the bandwidth of the signal. 1095 01:00:44,670 --> 01:00:51,170 [AUDIO OUT] bandwidth B. 1096 01:00:51,170 --> 01:00:55,740 So if the sampling rate is less than twice the bandwidth, 1097 01:00:55,740 --> 01:00:57,400 what happens? 1098 01:00:57,400 --> 01:01:00,180 That means delta t is too big. 1099 01:01:00,180 --> 01:01:06,260 These copies of the spectrum are too close to [AUDIO OUT] 1100 01:01:06,260 --> 01:01:08,850 and they overlap. 1101 01:01:08,850 --> 01:01:11,350 That overlap is called aliasing-- 1102 01:01:11,350 --> 01:01:12,510 a-l-i-a-s-i-n-g. 1103 01:01:15,250 --> 01:01:18,150 OK? 1104 01:01:18,150 --> 01:01:22,920 So you can see that if you sample a signal at too low 1105 01:01:22,920 --> 01:01:28,170 a sampling rate and you look at the spectrum of the signal, 1106 01:01:28,170 --> 01:01:30,570 you see that it has-- 1107 01:01:30,570 --> 01:01:34,390 like you'll see this part of the spectrum, 1108 01:01:34,390 --> 01:01:36,120 but you'll also see this other part 1109 01:01:36,120 --> 01:01:39,570 of the spectrum kind of contaminating the top 1110 01:01:39,570 --> 01:01:41,996 of your Fourier transform. 1111 01:01:41,996 --> 01:01:43,130 Does that makes sense? 1112 01:01:46,060 --> 01:01:46,620 OK. 1113 01:01:46,620 --> 01:01:49,350 So let me just say it again. 1114 01:01:49,350 --> 01:01:53,400 If your signal has some bandwidth B that in order 1115 01:01:53,400 --> 01:01:57,600 to sample that signal properly, your sampling rate 1116 01:01:57,600 --> 01:02:05,205 needs to be greater than twice that bandwidth, 1, 2. 1117 01:02:05,205 --> 01:02:05,705 OK? 1118 01:02:08,675 --> 01:02:10,430 All right, any questions about that? 1119 01:02:13,730 --> 01:02:19,550 Actually, there was actually recently 1120 01:02:19,550 --> 01:02:21,762 a paper where somebody claimed-- 1121 01:02:21,762 --> 01:02:23,720 I think I told you about this last time-- there 1122 01:02:23,720 --> 01:02:25,700 was a paper where somebody claimed to be 1123 01:02:25,700 --> 01:02:29,240 able to get around this limit. 1124 01:02:29,240 --> 01:02:37,490 And they were mercilessly treated in the responses 1125 01:02:37,490 --> 01:02:38,510 to that paper. 1126 01:02:38,510 --> 01:02:41,360 So don't make that mistake. 1127 01:02:46,140 --> 01:02:50,160 Now, what's really cool is that if the sampling 1128 01:02:50,160 --> 01:02:52,620 rate is greater than twice the bandwidth, 1129 01:02:52,620 --> 01:02:55,860 something amazing happens. 1130 01:02:55,860 --> 01:02:58,800 You can perfectly reconstruct the signal. 1131 01:03:01,464 --> 01:03:03,380 Now that's an amazing claim. 1132 01:03:03,380 --> 01:03:03,880 Right? 1133 01:03:03,880 --> 01:03:05,530 You have a [AUDIO OUT] time. 1134 01:03:05,530 --> 01:03:08,090 All right, it's wiggling around. 1135 01:03:08,090 --> 01:03:09,920 What this is saying is that I can 1136 01:03:09,920 --> 01:03:15,280 sample that signal at regular intervals 1137 01:03:15,280 --> 01:03:17,320 and completely ignore what's happening 1138 01:03:17,320 --> 01:03:20,740 between those samples, have no knowledge of what's happening 1139 01:03:20,740 --> 01:03:22,390 between those samples. 1140 01:03:22,390 --> 01:03:25,670 And I can perfectly reconstruct the signal 1141 01:03:25,670 --> 01:03:33,197 I'm sampling at every time point, 1142 01:03:33,197 --> 01:03:34,530 even though I didn't look there. 1143 01:03:42,080 --> 01:03:43,390 So how do you do that? 1144 01:03:43,390 --> 01:03:48,580 Basically, your sampled signal, you're regularly sampled 1145 01:03:48,580 --> 01:03:51,190 signal, has this spectrum-- 1146 01:03:51,190 --> 01:03:55,150 has this Fourier transform with repeated copies 1147 01:03:55,150 --> 01:04:01,590 of the signal, repeated copies of the spectrum. 1148 01:04:01,590 --> 01:04:06,780 So how would I recover the spectrum's original signal? 1149 01:04:06,780 --> 01:04:09,270 Well, the spectrum of the original signal 1150 01:04:09,270 --> 01:04:12,080 is just this piece right here. 1151 01:04:12,080 --> 01:04:19,040 So all I do is in the frequency domain I take that part. 1152 01:04:19,040 --> 01:04:21,440 I keep this, and I throw away all those. 1153 01:04:21,440 --> 01:04:26,210 In other words, I multiply my Fourier transfer sampled signal 1154 01:04:26,210 --> 01:04:32,900 in the frequency domain by a square pulse that's 1155 01:04:32,900 --> 01:04:36,656 1 here and 0 everywhere else. 1156 01:04:36,656 --> 01:04:37,790 Does that makes sense? 1157 01:04:43,890 --> 01:04:48,210 And when I inverse Fourier transform that I've completely 1158 01:04:48,210 --> 01:04:49,950 recovered my original signal. 1159 01:04:49,950 --> 01:04:53,760 What is multiplying this spectrum 1160 01:04:53,760 --> 01:04:57,120 by the square wave in the frequency domain equivalent 1161 01:04:57,120 --> 01:04:59,763 to in the time domain? 1162 01:04:59,763 --> 01:05:01,150 AUDIENCE: So I was going to ask-- 1163 01:05:01,150 --> 01:05:01,900 MICHALE FEE: Yeah. 1164 01:05:01,900 --> 01:05:06,010 AUDIENCE: [INAUDIBLE] 1165 01:05:06,010 --> 01:05:06,760 MICHALE FEE: Yeah. 1166 01:05:06,760 --> 01:05:09,500 AUDIENCE: So why do you want to do that? 1167 01:05:09,500 --> 01:05:11,390 MICHALE FEE: Yeah, so it's amazing, right? 1168 01:05:11,390 --> 01:05:11,970 It's cool. 1169 01:05:11,970 --> 01:05:15,480 So let me just what it is. 1170 01:05:15,480 --> 01:05:19,720 And then we can marvel at how that could possibly be. 1171 01:05:19,720 --> 01:05:23,110 Multiplying this spectrum by this square wave, 1172 01:05:23,110 --> 01:05:26,350 throwing away all those other copies of the spectrum 1173 01:05:26,350 --> 01:05:28,090 and keeping that one is multiplying 1174 01:05:28,090 --> 01:05:30,110 by a square wave in the frequency domain, 1175 01:05:30,110 --> 01:05:32,355 which is like doing what? 1176 01:05:32,355 --> 01:05:33,230 AUDIENCE: Convolving. 1177 01:05:33,230 --> 01:05:36,050 MICHALE FEE: Convolving the time domain sinc-- 1178 01:05:36,050 --> 01:05:39,740 that regular train of samples, convolving that 1179 01:05:39,740 --> 01:05:42,140 with a sinc function. 1180 01:05:42,140 --> 01:05:44,180 So let me just say that. 1181 01:05:44,180 --> 01:05:46,340 Here, we have a function that we've regularly 1182 01:05:46,340 --> 01:05:49,260 sampled at these intervals. 1183 01:05:49,260 --> 01:05:53,270 If we take that function, which is a bunch of delta functions 1184 01:05:53,270 --> 01:05:56,480 here, here, here, here, just samples, 1185 01:05:56,480 --> 01:06:00,750 and we can evolve that with a sinc function, 1186 01:06:00,750 --> 01:06:03,210 we perfectly reconstruct the original signal. 1187 01:06:13,420 --> 01:06:16,190 Pretty wild. 1188 01:06:16,190 --> 01:06:18,580 So that's the Nyquist-Shannon theorem. 1189 01:06:18,580 --> 01:06:20,680 What it says is that we can perfectly 1190 01:06:20,680 --> 01:06:24,520 reconstruct the signal we've sampled as long as we sample it 1191 01:06:24,520 --> 01:06:27,550 at a sampling rate that's greater than twice 1192 01:06:27,550 --> 01:06:29,616 the bandwidth of the signal. 1193 01:06:29,616 --> 01:06:32,460 OK? 1194 01:06:32,460 --> 01:06:34,040 All right. 1195 01:06:34,040 --> 01:06:34,690 OK, good. 1196 01:06:45,060 --> 01:06:50,850 So there's this cute trick called zero-padding, 1197 01:06:50,850 --> 01:06:55,200 where you don't perfectly reconstruct 1198 01:06:55,200 --> 01:07:00,270 the original signal, but basically you can interpolate. 1199 01:07:00,270 --> 01:07:05,550 So you can extract the values of the original signal 1200 01:07:05,550 --> 01:07:08,500 times between where you actually sampled it. 1201 01:07:08,500 --> 01:07:09,000 OK? 1202 01:07:09,000 --> 01:07:12,480 And basically the trick is as follows. 1203 01:07:12,480 --> 01:07:14,250 We take our sampled signal. 1204 01:07:14,250 --> 01:07:16,500 We Fourier transform it. 1205 01:07:16,500 --> 01:07:19,350 And what we do is we just add zeros. 1206 01:07:19,350 --> 01:07:22,930 We pad that Fourier transform with zeros. 1207 01:07:22,930 --> 01:07:23,490 OK? 1208 01:07:23,490 --> 01:07:27,182 So we just take positive frequencies 1209 01:07:27,182 --> 01:07:28,890 and the negative frequencies, and we just 1210 01:07:28,890 --> 01:07:34,350 stick a bunch of zeros between and make it a longer vector. 1211 01:07:34,350 --> 01:07:38,990 And then when we inverse Fourier transform this, 1212 01:07:38,990 --> 01:07:41,635 you can see that you have a longer array. 1213 01:07:41,635 --> 01:07:44,300 When you inverse transform, inverse Fourier 1214 01:07:44,300 --> 01:07:46,760 transform, what you're going to have 1215 01:07:46,760 --> 01:07:52,490 is your original samples back, plus a bunch of samples 1216 01:07:52,490 --> 01:07:55,990 in between that interpolate, that 1217 01:07:55,990 --> 01:07:59,920 are measures of the original signal at the times 1218 01:07:59,920 --> 01:08:02,830 where you didn't measure it. 1219 01:08:02,830 --> 01:08:08,150 So you can essentially increase the sampling rate 1220 01:08:08,150 --> 01:08:12,260 of your signal after the fact. 1221 01:08:12,260 --> 01:08:13,360 Pretty cool, right? 1222 01:08:13,360 --> 01:08:18,520 Again, it requires that you've sampled at twice the bandwidth 1223 01:08:18,520 --> 01:08:19,670 of the original signal. 1224 01:08:19,670 --> 01:08:20,396 Yes. 1225 01:08:20,396 --> 01:08:22,229 AUDIENCE: Like how do you know the bandwidth 1226 01:08:22,229 --> 01:08:26,649 of the original signal if you don't have samples? 1227 01:08:26,649 --> 01:08:28,300 MICHALE FEE: Good question. 1228 01:08:28,300 --> 01:08:29,740 How might you do that? 1229 01:08:34,033 --> 01:08:36,418 AUDIENCE: Can you like [INAUDIBLE] different sampling 1230 01:08:36,418 --> 01:08:37,859 lengths to get [INAUDIBLE] 1231 01:08:37,859 --> 01:08:39,840 MICHALE FEE: You could do that. 1232 01:08:39,840 --> 01:08:42,450 From nearly all applications, you 1233 01:08:42,450 --> 01:08:46,380 have a pretty good sense of what the frequencies are that you're 1234 01:08:46,380 --> 01:08:48,899 interested in a signal. 1235 01:08:48,899 --> 01:08:52,050 And then what you do is you have to put 1236 01:08:52,050 --> 01:08:57,870 a filter between your experiment and your computer that's 1237 01:08:57,870 --> 01:09:00,840 doing the sampling that guarantees 1238 01:09:00,840 --> 01:09:06,560 that it's suppressed all the frequencies above some point. 1239 01:09:06,560 --> 01:09:07,260 OK? 1240 01:09:07,260 --> 01:09:11,970 And that kind of filter is called an anti-aliasing filter. 1241 01:09:11,970 --> 01:09:15,540 So in that case, even if your signal had higher frequency 1242 01:09:15,540 --> 01:09:18,990 components, the anti-aliasing filter 1243 01:09:18,990 --> 01:09:23,790 cuts it off so that there's nothing at higher frequencies. 1244 01:09:23,790 --> 01:09:24,880 Does that makes sense? 1245 01:09:32,899 --> 01:09:35,540 Let me give you an example of aliasing. 1246 01:09:35,540 --> 01:09:37,864 Let's say I had this signal like this. 1247 01:09:40,950 --> 01:09:50,760 And I sample it here, here, here, here, here, here. 1248 01:09:50,760 --> 01:09:53,300 I need to do regular intervals. 1249 01:09:53,300 --> 01:09:58,550 So you can see that if I have a sine wave that 1250 01:09:58,550 --> 01:10:02,810 is close in frequency to the sampling rate, 1251 01:10:02,810 --> 01:10:10,750 you can see that when I sample the signal, 1252 01:10:10,750 --> 01:10:13,990 I'm going to see something at the wrong frequency. 1253 01:10:13,990 --> 01:10:16,469 That's an example of aliasing. 1254 01:10:16,469 --> 01:10:16,969 OK? 1255 01:10:21,910 --> 01:10:23,080 OK, so here's an example. 1256 01:10:23,080 --> 01:10:25,220 We have a 20 hertz cosine wave. 1257 01:10:25,220 --> 01:10:27,550 I've sampled it at 100 hertz. 1258 01:10:27,550 --> 01:10:30,950 So I'm, you know, 5-- 1259 01:10:30,950 --> 01:10:34,720 so what frequency would I have to sample this in order 1260 01:10:34,720 --> 01:10:37,840 to reconstruct the cosine? 1261 01:10:37,840 --> 01:10:39,940 I'd have to sample at least 40 hertz. 1262 01:10:39,940 --> 01:10:42,020 Here, I'm sampling at 100. 1263 01:10:42,020 --> 01:10:44,620 The delta t is 10 milliseconds. 1264 01:10:44,620 --> 01:10:47,290 So those are the blue points. 1265 01:10:47,290 --> 01:10:49,600 And now, if I do this zero-padding trick, 1266 01:10:49,600 --> 01:10:51,790 I Fourier transform. 1267 01:10:51,790 --> 01:10:54,750 I do zero-padding by a factor of 4. 1268 01:10:54,750 --> 01:10:58,600 That means if I take the Fourier transform signal 1269 01:10:58,600 --> 01:11:01,810 and I'm now making that vector 4 times as long 1270 01:11:01,810 --> 01:11:05,770 by filling in zeros, then I inverse Fourier transform. 1271 01:11:05,770 --> 01:11:08,260 You can see that the red points show 1272 01:11:08,260 --> 01:11:13,580 the interpolated values of that function after zero-padding. 1273 01:11:13,580 --> 01:11:14,210 OK? 1274 01:11:14,210 --> 01:11:18,140 So it can be a very useful trick. 1275 01:11:18,140 --> 01:11:22,790 You can also sample the signal in the time domain 1276 01:11:22,790 --> 01:11:25,760 and then add a bunch of zeros to it before you 1277 01:11:25,760 --> 01:11:26,720 Fourier transform. 1278 01:11:26,720 --> 01:11:30,740 And that gives you finer samples in the frequency domain. 1279 01:11:30,740 --> 01:11:31,240 OK? 1280 01:11:36,000 --> 01:11:37,120 And I think that's-- 1281 01:11:37,120 --> 01:11:38,740 so zero-padding in the time domain 1282 01:11:38,740 --> 01:11:42,500 gives you finer spacing in the frequency domain. 1283 01:11:42,500 --> 01:11:45,280 And I'll show you in more detail how to do this 1284 01:11:45,280 --> 01:11:48,550 after we talk about tapering. 1285 01:11:48,550 --> 01:11:52,690 And it's very simple code actually. 1286 01:11:52,690 --> 01:11:57,460 Matlab has built into it the ability 1287 01:11:57,460 --> 01:12:02,250 to do zero-padding right in the FFT function. 1288 01:12:02,250 --> 01:12:08,800 OK, let's actually just stop there. 1289 01:12:08,800 --> 01:12:15,300 I feel like we covered a lot of stuff today.