Return to Video

W01_L03_P01 - Averaging over white-noise in signals

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

English subtitles

Revisions