A2-A3A "non-answer" to Question 3Basically, because we're dealing with discrete signals and binomial filters, there are no "really right" answers. An explanation is below. So, you get credit for this providing you put anything reasonable. Or just anything at all. However, reading thing might help you understand the filtering better. The quick answer is: Part 1:A signal that is clearly too high frequency should be tried, if it aliases badly, then the filter cutoff is too high. A fast square wave is a good example for this test. A signal that should be OK to sample should look like a spead up version of itself. A square wave with a half-cycle of 3 or more would be an OK test. If this got too blurry, then the frequency cutoff is too low. However, since all square waves have high frequencies, we expect some blurring. Note: the question called for 1 signal, but as I'll explain below, that's a tall order. The best thing if you wanted to follow the letter of the law would be to have a signal that mixed a high frequency and a low frequency: [... 0 1 0 1 0 1 8 9 8 9 8 9 0 1 0 1 0 1 8 9 8 9 8 9 0 1 0 1 0 1 8 9 8 9 8 9 ...]
Part 2:An exact answer is tough - especially since you don't have real sine waves to test with. Generally, the first few binomials (the narrowest ones) have too high a cutoff, so they will allow too many high frequencies and aliasing. Personally, I think the answer is either 1/8 [1 3 3 1] or 1/16 [1 4 6 4 1], but as we'll see, that'a a matter of taste. Getting the frequency limit "just right"...First, a warning: when dealing with discrete signals, square waves, and simple filters, the math of sampling theory doesn't always work out as nicely - the examples aren't quite so clean. Consider downsampling a signal by a factor of 3. This means we'll take every third sample. If the signal has frequencies in it that are too high, we will alias when we downsample. Therefore we need to use a low pass filter (or an approximation to a low-pass filter) before we pick the new samples. Think about this in terms of square waves. If the square wave is 3 samples in each phase, we can represent it in the downsampled signal. Note that technically, this signal is just at the Nyquist rate, so its kindof lucky that things work out. So if the signal is: [ ... 8 8 8 0 0 0 8 8 8 0 0 0 8 8 8 0 0 0 ... ]
We would get [ ... 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 0 ... ]
If the square wave is faster than 3 (I'll call this w=3) samples in each phase (so each phases is shorter), we get aliasing. Consider a square wave with 2 samples in each phase. You'd expect that since the input is faster than the (w=2), the output would oscillate faster. Of course, it can't, so all we can get is aliasing. [... 8 8 0 0 8 8 0 0 8 8 0 0 8 8 0 0 8 8 0 0 8 8 0 0 8 ...]
take every third and we get... [... 8 0 0 8 0 0 0 8 8 0 0...]
Notice that there's a slow (and somewhat irregular) cycle, but we didn't get a faster cycle than the w=3 square wave. That low frequency is an alias of the higher frequency that we can't see. Or, if we have the highest frequency (w=1) square wave: [... 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 0 ...]
we get: [... 8 0 8 0 8 0 8 0 8 0 8 0 ...]
So w=1 and w=3 are aliases of each other! Now let's try w=4: [... 8 8 8 8 0 0 0 0 8 8 8 8 0 0 0 0 8 8 8 8 0 0 0 0 8 8 8 8 0 0 0 0 8 8 8 8 0 0 0 0 8 8 8 8 ...]
take every third sample, we get: [... 8 8 0 8 0 0 8 0 8 0 8 8 0 8 0 0 8 0 8 ...]
This might not seem better than the aliasing case of w=2, because of the irregularity. But that irregularity is coming from the fact that we're trying to make a square wave of w=4/3, even though we're just sampling at the integers, so its OK. Every cycle of the original square wave appears. Which gives us another way to think about this: if the pulses are small enough (high enough frequency) that they might be missed by sampling, we get aliasing. Consider: [... 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 ...]
and we get [... 0 0 0 0 0 0 0 0 0 0 0 0 ...]
Or, if we choose our starting phase in an unlucky way... [... 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 ...]
Here, the pulses alias themselves as a DC value - its just that we get a different DC value depending on what the phase is! So, clearly we need to do some low-pass filtering to get rid of the high frequencies, and get rid of these high frequencies that are aliasing. A warning though: because we'll be using simple filters, we won't get rid of all the aliasing, but hopefully we'll make it better. But what cutoff frequency should we make the low-pass filter? If we make the cutoff frequency too high (that is, we leave in high frequencies that we shouldn't) we'll get too much aliasing. If we make the cutoff frequency too low (that is we cut out high frequencies that aren't too high) we'll be removing some things that we should be able to reproduce. To use the examples above, we definitely want to cut out the w=1 and w=2 waves, we don't want to cut out the w=4 waves. The w=3 waves seem ok. So, let's suppose I had downsampling with the correct filter. We'd hope that if I fed it the w=1 or w=2 waves, it would cut them out (and I'd get a DC or constant value of the average, which is 4). We'd hope that if I fed it the w=4 wave, it would go through OK. Now, in the ideal world, we could just add w=1 to w=4 to get a single test signal, and our ideal filter could pick them apart. In the real world, (especially the simplified one we're dealing with using these drastic downsamplings and simple filters), its probably best to test with 2 different signals. So let's see what happens with some real filters that we know about. The only ones we talked about much in class are the binomial filters: 1/2 [ 1 1 ]
1/4 [ 1 2 1 ]
1/8 [ 1 3 3 1 ]
1/16 [ 1 4 6 4 1 ]
1/32 [ 1 5 10 10 5 1 ]
The smallest one (1 1) has the highest frequency cutoff. As they get bigger, they cut lower and lower frequencies. Because these aren't ideal low-pass filters, they don't remove all the high frequencies. Let's see what happens when I start running these different binomial filters on a signal I know has too high a frequency content. No Filter: [... 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 0 0 8 ...]
Filter by 1/2 [1 1] [... 4 4 0 4 4 0 4 4 0 4 4 0 4 4 0 4 4 0 4 ...]
Filter by 1/4 [1 2 1] [... 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 ...]
Filter by 1/8 [1 3 3 1] [... 3 2 3 3 2 3 3 2 2 3 2 2 3 2 2 3 2 2 3 ...]
Filter by 1/16 [1 4 6 4 1] [... 2.5 2.5 3 2.5 2.5 2.5 3 2.5 2.5 2.5 3 2.5 2.5 3 ...]
An ideal low-pass filter would give a constant 8/3. Notice that each time the amount of high frequencies is decreased (the size of the little bumps), and things are getting closer to that ideal LPF. Because we don't have a "real" low pass filter, we don't really get rid of the high frequencies. So you might wonder, which one of these is "right" - well, its hard to say. None of them really (since they all let a little bit of the high frequency in). In each case, we still alias to a DC value, but in the latter ones, the error from aliasing is small. Notice that any of these filters can get rid of the w=1 signal. [... 8 0 8 0 8 0 8 0 8 0 8 0 8 0 8 ...]
Filter by 1/2 [1 1] (or any of the others) [... 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...]
If we try w=2, we get: [... 8 8 0 0 8 8 0 0 8 8 0 0 8 8 0 0 8 8 0 0 ...]
[... 8 4 0 4 8 4 0 4 8 4 0 4 8 4 0 4 8 4 0 4 ...]
[... 6 2 2 6 6 2 2 6 6 2 2 6 6 2 2 6 6 2 2 6 ...]
[... 4 2 4 6 4 2 4 6 4 2 4 6 4 2 4 6 4 2 4 6 ...]
[... 3 3 5 5 3 3 5 5 3 3 5 5 3 3 5 5 3 3 5 5 ...]
[... 3 4 5 4 3 4 5 4 3 4 5 4 3 4 5 4 3 4 5 4 ...]
(by the way, to do these series of filterings easily, we can just keep repeating the filtering by 1/2 [1 1]) Again, notice how the filter keeps reducing the high frequency, but it doesn't completely make it go away. So how do you actually pick?Square waves and pulses are the worst case. So the fact that no filter seems to do a good job isn't cause for too much concern - especially since we're just using simple binomial filters. For downsampling, we want to make sure that we don't miss anything. So if there is a stray speck, we at least pick it up a little. For the down sample by 3 case, the 2nd binomial filter [1 2 1] spreads out a spike wide enough that it won't be missed. In practice, having the edges of the kernels overlap a bit is desireable, so we'd probably choose [1 3 3 1] or [1 4 6 4 1]. Note, that if you put in a lower frequency square wave, it would but cut down by any of these. The bigger the filter, the more it gets cut down. With w=4, even with [1 4 6 4 1] you get a pretty strong wave (not square, since the high frequencies required for the edges have been cut out). |