-
So, before we start talking. A couple
things that we want, you want to
-
understand. So, we talked about how to do
filtering. So, you have this center
-
frequency, right? And you have this noisy
signal. And let's say, in the frequency
-
domain, there's my version of noise, okay?
You get to all this junk, right? Any
-
ideas, you say is there anything there or
not? And then, you would put like some
-
kind of filter cuz you know what
frequencies you're going to look at. And
-
then, you basically multiply these two
together, kill everything off. Okay, so
-
that's one way to do things. Now, couple
things to notice about this. First, I know
-
where to look. Now in a radar problem
generically, you don't know where to look.
-
But in your DOG problem, I'm not letting,
I'm not telling you what frequency to look
-
for. You've got to find it, okay? There's
one other piece of information we haven't
-
used here, okay? The other piece of
information we haven't used here is, is
-
something about the noise itself. What did
we say this noise was? We say this noise
-
was white noise. Now, the nice thing about
detectors is you can keep often times keep
-
resampling things, right? So, for
instance, if I'm in the radar problem,
-
right? Okay, that's my radar on top of a
mountain, and there's your airplane coming
-
in. Alright. That's a really bad airplane.
But anyway, there's my airplane coming in,
-
or missile, whatever happens to be and I'm
trying to get this thing. I can keep, I'm
-
continually taking continually taking
information in on this. So, I'm sampling
-
not just once, not just twice, but I have
a continual sample string, okay? So, I
-
haven't made use of that at all in this
filtering problem. So, I want to try to
-
think about how to make use of that. The
fact is, when you have white noise, here's
-
the specifics about white noise. White
noise is random. And, by the way, normally
-
when it's randomly distributed you say,
well, okay. So, how did I do, do it in my
-
computer? I said, mean zero, unit
variance. Okay? So, when I add two pieces
-
of noise together, they shou ld be
incoherent. If I have three, four, five,
-
six, none of it should be coherent. In
fact, I add a bunch of noise together and
-
I take its average and its average is
zero. Awesome. So I did one sample. What
-
if I took a bunch? Then, the idea would be
that if I took a bunch of noise, then if I
-
add all of the noise together, it should
be zero. And by the way, if it's not
-
noise, it won't go to zero. So, I'm going
to use that to your, to my advantage. But
-
really, that's like to your advantage,
too. Anything that's to my advantage right
-
now is to your advantage. Okay. The only
thing that's to my advantage and not to
-
your advantage is my, maybe the homework.
Cuz then I already wrote it. You got to do
-
it. So, okay. So, so we're going to try to
work on that and see how that can work for
-
us, okay? So, what I want to do is write
aother code today building upon what we
-
did last time with the aim of making, kind
of exploring this idea of what noise does,
-
okay? So, I'm going to turn the lights
down in front. Now, you guys in the back
-
there, the TV screens, what do you got
there on the TV screens? Chow, can you see
-
my can, computer? Alright, great. Okay.
Alright. So, here we go. We're going to
-
start of with a little bit of code we had
last time. So, here it is. Let's just go
-
through it again. You'll be writing a lot
of code like this in your homework, first
-
homework for instance. And of course,
hopefully everybody likes these commands,
-
clear all, close all, clc. This just
starts us off on a fresh slate for the
-
code. And then here, I define a time
domain. So, I'm going to sample my signal
-
for 30 units. Whatever that happens to be.
Let's say, call it seconds. I'm going to
-
sample for 30 seconds. And what I want to
do with that 30 seconds and see what's,
-
what's in that signal. So, I get to have a
certain number of points I'm going to
-
sample with. So here, there's 512 points
and 30 seconds. So, I'd sample at that
-
rate, okay? And now, I can define my time
interval as well as my frequency
-
components in, in that sampling. So here,
thi s T2 and T. So, remember the lin space
-
is a linear space that goes from -T over
two to T over two, so it's negative
-
fifteen to fifteen. And I break it up into
512 plus one points. So, 512 points plus
-
the last point is the same as the first,
periodic. Using, remember I'm using
-
Fourier modes, Fourier coefficients. Those
are all sines and cosines of two pi
-
periodic, okay? Whenever you use Fourier
components, assumptions, periodic. So, I
-
got periodic and I throw away the last
point by just taking the first one through
-
n here. So, T is what I really want. And
then, I define my wave numbers or
-
frequency components, with two pi over T,
is there because the FFT thinks you're
-
working on a two pi periodic domain. So,
this is a re-scaling. And you go from zero
-
to n / two -one, and to n over, -n / two
-one.
-
These are like my cosine zero, my cosine
1x, and my cosine 2x. And they're
-
integers. And why do I order them this
way? Remember, the FFT shifts things,
-
okay? Ot does, it does one of these. So,
you've got your four components when you
-
do the FFT does that. Take a knife, cut it
in the middle of the main switches it
-
over. So is kn minus the number two to, n
over two. Yeah, so when you say that,
-
yeah, then I take away that shift. And now
it's just from -n over two to n over two,
-
but with a two pi over two factor in front
of it. Okay. Now, I'm going to define a
-
function, such. And it's Fourier transform
ut, okay? So, we have everything we've
-
got. We got a function, we have this
Fourier transform. And now, what we want
-
to do, and let me bring this up a little
bit. Does that, so there is my function
-
and such. There is its Fourier transform.
And I'm going to add some noise. There it
-
is. So, I take some, this is just going to
be some coefficient. It's going to control
-
how much noise I want to throw on this.
And notice the way I put white noise on,
-
you put it on the frequency domain. White
noise is a collection, right? If, white
-
noise is all colors, right? So, there's
also a thing called colored noise which
-
is, if you have certain frequen cy
components that have noise in it, well,
-
around those frequencies or colors, you
would add noise there. But if we do white
-
noises, all frequency components have
noise, okay? So, what I do here is I go to
-
every frequency component and add a random
variable. This is round in. It means zero
-
unit variants, okay? And I add both a real
and imaginary part. Just do my signal. So,
-
I've, I've modified my signal made it not
so nice. Yeah. Could you explain one more
-
time why you need to add the imaginary
noise as well? Yeah. So, if you do not
-
have this imaginary piece, what you've
added only is real components into your
-
noise. It makes it symmetric. Remember,
when think about your frequency
-
components, it's e to the i. When you do a
Fourier transform, it's e to the i
-
whatever the, the frequency component has
to be. Well, if you only add e to the i
-
with real component, then what happens is,
right? You're saying, okay, I'll add e to
-
the i. But then, e to the -i looks the
same. So, what ends up happening then it,
-
at symmetric noise. You don't want to do
that. And if you only add the imaginary
-
parts, you add a symmetric noise. So, you
add both to get, so there's no correlation
-
between the cosine i omega terms and the
cosine -one omega terms, both of them get
-
different noise, okay? Alright. Good?
Alright. Dealing with a lot of this
-
Hawaiian thing these days, I don't know
why I just developed it in last quarter
-
where I was doing a lot of this. It's a
little shocker, you know? So, if you see a
-
lot of that, I mean, I don't know what
that means. Except I think maybe I'm
-
having a good time in class, yeah? Oh,
that's not so good. Alright. we'll see how
-
long that lasts. But I, kind of like it.
Hawaii made me think of the sunshine,
-
that's a good thing to think about. Okay.
So then, I have my new signal, utn. Can
-
you guys still see my screen back there?
Or is that me, there we go. Perfect.
-
Alright. u of n. u of n is my noisy
signal. So let's plot these, just to take
-
a look. So you know, we'll subplot them.
Subplot oh, by the way, see, I also want
-
to, remember I have this k of s here?
That's a shifted version, I want you to
-
just remember that I've already done that.
So, I'll make a subplot of two rows, one
-
column. And first, we're going to plot the
original signal, t versus u. And we'll
-
plot that in red. And then, we'll plot
this noisy signal, t versus absolute value
-
of un, plot that in black. And then,
second subplot we'll plot, first of all,
-
we'll plot the nice spectrum, which is ks
versus the absolute value of ut which is
-
the transform. Oh, by the way, FFT shift
of ut. And plot that in red. And now,
-
we'll plot the noisy part which is ks
versus absolute value of FFT shift utn.
-
And I think, there we go. Alright. So,
we'll just plot what these things look
-
like. Here they are. Okay. So, the red is
my clean signal. The black is my muddled
-
signal because it got polluted with noise.
The red is my nice clean spectrum. And all
-
that blue is the fact that I added noise
at all these components. So, normally what
-
you're going to read from your detectors,
the.