DSPRelated.com
Forums

Linear-phase FIR filter coefficient properties

Started by m26k9 August 18, 2010
Thank you very much r b-j.

>it's a filter with real coefficients. if your input is complex, then >either internally, the FIR knows how to do a real x complex + complex - >> complex multiply-accumulate. or, it's like to have two parallel >real filters with identical real coefficients, and one is working on >the real part of your complex input and the other is working on the >imaginary part. since all of the coefficients are real, there is no >crosstalk between these two filters. reals stay real, imaginary parts >stay imaginary.
I understand that it can two parallel filters working on the real and imaginary parts of a complex signal, but this is only if the filter has real coefficients. In case the filter is complex, then we cannot have two parallel filters, can we? We need to do 4 multiplications/tap and cannot process the real and imaginary parts individually, right? Or are you implying that all filters have real coefficients only when you say "it's a filter with real coefficients"? Thank you very much.
On Aug 22, 11:35�pm, "m26k9"
<maduranga.liyanage@n_o_s_p_a_m.gmail.com> wrote:
> Thank you very much r b-j. > > >it's a filter with real coefficients. &#4294967295;if your input is complex, then > >either internally, the FIR knows how to do a real x complex + complex - > >> complex &#4294967295;multiply-accumulate. &#4294967295;or, it's like to have two parallel > >real filters with identical real coefficients, and one is working on > >the real part of your complex input and the other is working on the > >imaginary part. &#4294967295;since all of the coefficients are real, there is no > >crosstalk between these two filters. &#4294967295;reals stay real, imaginary parts > >stay imaginary. > > I understand that it can two parallel filters working on the real and > imaginary parts of a complex signal, but this is only if the filter has > real coefficients. > > In case the filter is complex, then we cannot have two parallel filters, > can we? We need to do 4 multiplications/tap and cannot process the real and > imaginary parts individually, right?
not precisely. now there are 4 FIR filters, two identical pairs, one pair has the real part of the complex h[n], the other pair has the imaginary part of h[n]. you can process each of the real input and the imaginary input individually with one each of the pair... so far everything is separate, then at the final real and imaginary outputs, you combine the FIR outputs according to the rules of complex number multiplication. .------------. .----> Re{ x[n] } --.---->| Re{ h[n] } |----> y1[n] | | '------------' | | | | .------------. | '---->| Im{ h[n] } |----> y2[n] | '------------' x[n] ---->| | | | .------------. '----> Im{ x[n] } --.---->| Re{ h[n] } |----> y3[n] | '------------' | | .------------. '---->| Im{ h[n] } |----> y4[n] '------------' then y[n] = Re{ y[n] } + j*Im{ y[n] } and Re{ y[n] } = y1[n] - y4[n] Im{ y[n] } = y2[n] + y3[n]
> Or are you implying that all filters have real coefficients only when you > say "it's a filter with real coefficients"?
when you actually do something real in reality, you will be doing it with real numbers. *even* if you are doing DSP on complex-valued signals. you are really doing it to their real and imaginary parts according to sensible rules we learned about arithmetic regarding complex numbers. now, all of this complex coefficient thingie is *independent* of whether or not it is linear phase. r b-j
m26k9 wrote:
>> "Why linear phase?" > > Actually the specification I have is just the frequency magnitudes so I was > working under the assumption that the channel phase distortion is linear. > This could very well not be the case, but right now I am only worried about > getting the theory understood.
***OK. It is almost certainly *not* linear phase. That would be most unusual.
> > >> No matter the approach, you start with a real "ideal" real frequency >> response that is symmetrical about zero in frequency which when windowed >> remains so. When inverse transformed it ends up with a filter that has >> real coefficients. That's just the normal thing. > > Why do I start with a "real" frequency and then window it to get real > coefficients? This seems like the "frequency sampling method" algorithm.
***The algorithm has nothing to do with it. This applies to all methods. You can skip the windowing or not ... that's a choice you make.
> > Let me give this example, which is also what I actually want to do, and > please tell me if I am wrong. > > Consider a DMT system, the transmitter end. The ifft routine is input with > 'N' complex QAM symbols. The output is then complex and asymmetric about > f=0 (because the input QAM data are complex). Now this output has frequency > components going from (-N/2) to (N/2), where H[f]!=H*[-f], 0<f<N/2. It is > asymmetric.
***OK - I don't understand DMT well but OK.
> > Case 1) > I want to equalize this (complex and asymmetric) output according to a > desired frequency response G[f], where -N/2<f<N/2. And the response of G[f] > is asymmetric (as will be in most cases). So G[f]!=G*[-f], 0<f<N/2. > > Now, since the frequency response of G[f] is asymmetric, I must have a > complex filter, right?
***Yes, a filter designed to meet the specified frequency response will generally have complex coefficients.
> > Case 2) > Although my signal spectrum is asymmetric, I want to equalize them in a > symmetric way (just a hypothetical case probably not done is practice). My > filter response is thus, symmetric, giving G[f]=G*[-f], 0<f<N/2. > > Now in "this" case, I can have a filter that has real coefficients because > it is symmetric, right?
***Yes ... as long as the real and complex modifiers are being applied to the temporal filter - which is what you mean when you say "coefficients". Just to make sure I'm being clear what "yes" means.
> > Few questions I want to ask. > > Q1) In both case 1 and case 2, whether the filter is real or complex was > dependent on the frequency spectrum of the filter (symmetric or > asymmetric), and not whether the input signal is real or complex.
***Correct.
> > Q2) I have not taken in to account of the phase response of the filter. > Does the phase response have connection to whether the filter is real or > complex?
***Just consider that phase is computed from the real and imaginary parts arctan(Im/Re) in its simplest form. So, that's like asking if either the real or the imaginary part has anything to do with whether the filter is real or complex (in time). I mean, I could have a symmetric filter without it being
> linear-phase right?
***No. In other words, a filter can be real but not linear
> phase, can it not? >
***Yes - but not "in other words" Example [1 1 0.5] is real and not linear phase. The difference or confusion here is between "symmetric" in the first statement and "real" in the second statment. Unless you meant "real" in the frequency domain. In that case "it depends". I'll start in the time domain: - If the filter is real and even about its center then the Fourier Transform (for the center at t=0) is real and even and the phase is linear (fixed delay). - If the filter is real and not even about its center (which means it also has an odd part) then the Fourier Transform is complex and phase is generally not linear (even for the center at t=0). [As I mentioned earlier, indexing can cloud this. For example, if you take the time response of a filter and *start* it at t=0 then it will perforce be not purely even about t=0 and the Fourier Transform will be complex. But, if it's even about its own center then it will still be linear phase. So, the idea is to put t=0 at the center of the filter unit sample response for analysis purposes.] - If the filter is real in time that doesn't make it even about its center. If it's not even then it's not linear phase. - If the filter is real in frequency then the imaginary part in frequency is zero and the phase is zero (for the temporal center at t=0) - a special case of linear phase. For this to be the case, the temporal filter is purely even. If the temporal center isn't at zero but the evenness remains then the filter will be (nonzero) linear phase. Flat delay means Linear phase. A delay D causes a phase shift according to wT where D=T is the delay. Thus phase varies in direct proportion to the frequency when the delay D is fixed. If the delay D is a function of frequency D(w) then this relationship doesn't hold and you have not-linear phase. FIR filters can be described as: 1) minimum delay 2) linear phase (flat delay) 3) maximum delay For minumum delay, the filter's zeros are all inside the unit circle. For flat delay, the filter's zeros appear in reciprocal-magnitude pairs inside and outside the unit circle and the imaginary parts are mirrored to form a quad. For maximum delay, the filter's zeros are all outside the unit circle. Fred
Thank you very much r b-j.
> > > .------------. > .----> Re{ x[n] } --.---->| Re{ h[n] } |----> y1[n] > | | '------------' > | | > | | .------------. > | '---->| Im{ h[n] } |----> y2[n] > | '------------' > x[n] ---->| > | > | > | .------------. > '----> Im{ x[n] } --.---->| Re{ h[n] } |----> y3[n] > | '------------' > | > | .------------. > '---->| Im{ h[n] } |----> y4[n] > '------------' >
This one helped a lot! Thank you very much.
Thank you very much Fred once again for taking time to give a very
comprehensive explanation. 

>I'll start in the time domain: >- If the filter is real and even about its center then the Fourier >Transform (for the center at t=0) is real and even and the phase is >linear (fixed delay).
*** OK. Understood this part. Phase is linear because phase=0 (imaginary parts are all zero).
>- If the filter is real and not even about its center (which means it >also has an odd part) then the Fourier Transform is complex and phase is >generally not linear (even for the center at t=0).
*** Right. Understood so far. I also want to confirm that a filter with even coefficients also means that the filter is symmetric (in time). And this makes the frequency response also real and even (symmetric).
>[As I mentioned earlier, indexing can cloud this. For example, if you >take the time response of a filter and *start* it at t=0 then it will >perforce be not purely even about t=0 and the Fourier Transform will be >complex. But, if it's even about its own center then it will still be >linear phase. So, the idea is to put t=0 at the center of the filter >unit sample response for analysis purposes.]
*** To confirm that I understood what you mean, this sequence is even (and symmetric), right? (It gives real and even frequency components). h = [4 3 2 1 1 2 3];
>- If the filter is real in time that doesn't make it even about its >center. If it's not even then it's not linear phase.
*** It's a little difficult to confirm from the texts because the keywords even, real and symmetry usually go together with linear-phase. I want to confirm, that property of linear phase is a consequence of evenness (conjugate symmetry) of the filter frequency response? Like you mentioned, if the filter (in time) is real and even, the frequency response is even and 'real'. Because it is real, the phase response is linear (phase=0). But this is just one special case. The property of linear phase comes from conjugate symmetry of frequency response, or there is no definite relation between linear phase and frequency response symmetry?
>If the temporal center isn't at zero but the evenness remains then the >filter will be (nonzero) linear phase. >
*** Little confused here Fred. Would you be kind enough give me a simple sequence that is even but not centered at zero? Does it mean a circularly shifted version of a even sequence? I'm very to trouble you with questions Fred. Thank you very much for all the effort and time. I very much appreciate it.
m26k9 wrote:
> Thank you very much Fred once again for taking time to give a very > comprehensive explanation. > >> I'll start in the time domain: >> - If the filter is real and even about its center then the Fourier >> Transform (for the center at t=0) is real and even and the phase is >> linear (fixed delay). > > *** OK. Understood this part. Phase is linear because phase=0 (imaginary > parts are all zero).
***Not exactly. If the filter is real and even about its center but *not* centered at t=0 then the Fourier Transform is complex and the phase is linear (fixed delay). The phase is only zero if the delay is zero and that's only the case when it's even and centered at t=0.
> >> - If the filter is real and not even about its center (which means it >> also has an odd part) then the Fourier Transform is complex and phase is >> generally not linear (even for the center at t=0). > > *** Right. Understood so far. > I also want to confirm that a filter with even coefficients also means that > the filter is symmetric (in time). And this makes the frequency response > also real and even (symmetric).
***You have to be careful. I would say it this way: A filter with even coefficients also means that the filter is symmetric (in time) *about its own center*. It's only when the center is at t=0 that the frequency response is also real and even (symmetric).
> >> [As I mentioned earlier, indexing can cloud this. For example, if you >> take the time response of a filter and *start* it at t=0 then it will >> perforce be not purely even about t=0 and the Fourier Transform will be >> complex. But, if it's even about its own center then it will still be >> linear phase. So, the idea is to put t=0 at the center of the filter >> unit sample response for analysis purposes.] > > *** To confirm that I understood what you mean, this sequence is even (and > symmetric), right? (It gives real and even frequency components). > h = [4 3 2 1 1 2 3];
***Yes, in a Matlab notation and FFT sense, this "h" represents a sequence that is even around the first sample and repeats at the presumed 8th sample or the repetition of the first sample.
> > >> - If the filter is real in time that doesn't make it even about its >> center. If it's not even then it's not linear phase. > > *** It's a little difficult to confirm from the texts because the keywords > even, real and symmetry usually go together with linear-phase. I want to > confirm, that property of linear phase is a consequence of evenness > (conjugate symmetry) of the filter frequency response?
***Yes, as above.
> > Like you mentioned, if the filter (in time) is real and even, the frequency > response is even and 'real'. Because it is real, the phase response is > linear (phase=0). But this is just one special case. The property of linear > phase comes from conjugate symmetry of frequency response, or there is no > definite relation between linear phase and frequency response symmetry?
***Well, again it pays to be careful and I've probably not been as careful as one might be. If a function is even then that implies it's center is at zero really doesn't it? So, in that case then real/even gets real/even and, yes, zero phase. But if you take one of these real/even temporal sequences and time shift it so that it's causal for example then the phase is due to that time shift / pure delay and the phase is linear.
> >> If the temporal center isn't at zero but the evenness remains then the >> filter will be (nonzero) linear phase.
***We probably shouldn't call it "even" then.... Even about its center perhaps or symmetric about its center might be better. But, I'm sure by now we know what we're referring to.
>> > > *** Little confused here Fred. Would you be kind enough give me a simple > sequence that is even but not centered at zero? Does it mean a circularly > shifted version of a even sequence?
h = [0 0 0 0 4 3 2 1 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0] This one is symmetric about its center and not centered at zero.... And, yes it could be circularly shifted to take the case you used: h = [2 1 1 2 3 4 4 3 ] I think that's right.... it gets just a little tricky when dealing with sequences that are thought of as periodic and here we are dealing with not quite a single period. Of course, if we were not assuming a DFT then we could just talk about a Fourier Transform of the sequence and, in that case might want to include the last sample as in: h = [4 3 2 1 1 2 3 4] I'm not sure how to explain this further without thinking about it as I've not spent much time explaining it.... Fred
Thank you very much again Fred. I really appreciate all your effort and
time.

I'm little confused about couple of points. If you could please explain a
bit I'd be really grateful.

I'm having trouble grasping these two points:
1) Even about its center
2) Centered at t=0

How do these two differ? For example cos[n] is even about n=0,pi,2pi,...
So we can't possibly assign a 'center' to cos[n], right? But  it's even and
the FT has real and even components. 

But I am thinking about a filter h[n], from a coefficients point of view,
and no as a function which I can define in 'n'. So filter h[n] will be a
sequence of coefficients. These coefficients can be real or positive. 

Now when we have a sequence h[n], how do we define it's center?

For example, when I gave the sequence h=[4 3 2 1 1 2 3] in the previous
post, I was thinking
h[0]=4;
h[1]=3;
h[2]=2;
h[3]=1;
h[4]=1;
h[5]=2;
h[6]=3;

And h[n]=h[7-n], making it even. I meant that (4,3,2,1) is mirrored by
(1,2,3) and that makes this sequence even. But you said "even around the
first sample and repeats at the presumed 8th sample".

Or we could also have a sequence:
h[-4]=4;
h[-3]=3;
h[-2]=2;
h[-1]=1;
h[ 0]=0;
h[ 1]=1;
h[ 2]=2;
h[ 3]=3;

This sequence is even about n=0, with h[n]=h[-n]. Both these sequences are
even (symmetric) and give real and even FT's.

If we take for example cos(x), and we take a sequence from -pi to pi, it
will be an even sequence about x=0. But if we take x from -0.3*pi to 1.3*pi
(arbitrary multipliers), then this sequence will not be even.

Am I going down a completely wrong line here?

You also mentioned "in FFT sense", do you mean there is a difference if I
consider DFT?

Again I'm very sorry to bother you Fred. I really want to get the theory
understood correctly. Thank you very much for your help.



m26k9 wrote:
> Thank you very much again Fred. I really appreciate all your effort and > time. > > I'm little confused about couple of points. If you could please explain a > bit I'd be really grateful. > > I'm having trouble grasping these two points: > 1) Even about its center > 2) Centered at t=0
1) Its center means, for a sequence indexed from 1 to N the center is at 1 + (N-1)/2. So, if N=3 then the center is at 2 and if N=4 then the center is at 2 1/2. The normal test for evenness is: f(t) = f(-t) The normal test of oddness is: f(t) = -f(-t) So, in the case of an offset T, we can substitute t-T for t. So, by even about its center, I meant a function that has this property: f(t-T) = f(-t+T) which is a more general case than just for T=0. It takes out the time offset, if any. Your (1) and (2) are a bit sloppy terminology: "1) Even about its center" means the above. "2) Centered at t=0" means that the sequence runs from -(N-1)/2 to (N-1)/2. If N is an odd number then there is a sample at t=0. If N is an even number then there is not a sample at zero and samples occur at noninteger values of time (of the sample interval) because (N-1)/2 has a fractional part. So, I'll add (3): 3) Not centered at t=0 but at T means that the sequence runs from [T - (N-1)/2] to [T + (N-1)/2]. This could be an example of a causal sequence where T is a positive number and >= (N-1)/2.
> > How do these two differ?
***As stated, they don't relate very well. That's why I restated and added. For example cos[n] is even about n=0,pi,2pi,...
> So we can't possibly assign a 'center' to cos[n], right? But it's even and > the FT has real and even components.
***I would say "it depends". Are we talking now about continuous and infinite functions like a sinusoid? That seems a switch in focus. If they are infinite then the same test above applies but you may as well use zero as the "center" or whatever point you decide is useful in your purpose. But, if we are talking about sampled data (I thought we were) and finite sequences then there is the matter of indexing and where you define zero time, etc.
> > But I am thinking about a filter h[n], from a coefficients point of view, > and no as a function which I can define in 'n'. So filter h[n] will be a > sequence of coefficients. These coefficients can be real or positive.
*Does that mean if they are positive that they can't be real??? :-(
> > Now when we have a sequence h[n], how do we define it's center? > > For example, when I gave the sequence h=[4 3 2 1 1 2 3] in the previous > post, I was thinking > h[0]=4; > h[1]=3; > h[2]=2; > h[3]=1; > h[4]=1; > h[5]=2; > h[6]=3; > > And h[n]=h[7-n], making it even. I meant that (4,3,2,1) is mirrored by > (1,2,3) and that makes this sequence even. But you said "even around the > first sample and repeats at the presumed 8th sample".
***You've taken what I said out of context. The complete statement was: "***Yes, in a Matlab notation and FFT sense, this "h" represents a sequence that is even around the first sample and repeats at the presumed 8th sample or the repetition of the first sample." In a Matlab notation and FFT sense it would be written: > h[1]=4; > h[2]=3; > h[3]=2; > h[4]=1; > h[5]=1; > h[6]=2; > h[7]=3; where h[1] is aligned with t=0. And, since it's treated as if circular then mapping this into sample times as g(n)and extending it: . . . . g[-10]=1 g[-9]=2 g[-8]=3 g[-7]=4 g[-6]=3 g[-5]=2 g[-4]=1 g[-3]=1 g[-2]=2 g[-1]=3 g[0]=4 g[1]=3 g[2]=2 g[3]=1 g[4]=1 g[5]=2 g[6]=3 g[7]=4 g[8]=3 g[9]=2 g[10]=1 . . . So, as you should be able to observe, this sequence is even about t=0 where the g[0] sample resides. Converting this to Matlab notation, g(n)=h(n+1) (where the negative and zero indices are undefined) and the sequence repeats after g(6) or h(7) at f(7) or the nonexistent h(8) which we assume is h(1). Thus as I said: "even around the first sample and repeats at the presumed 8th sample".
> > Or we could also have a sequence: > h[-4]=4; > h[-3]=3; > h[-2]=2; > h[-1]=1; > h[ 0]=0; > h[ 1]=1; > h[ 2]=2; > h[ 3]=3; > > This sequence is even about n=0, with h[n]=h[-n]. Both these sequences are > even (symmetric) and give real and even FT's.
***I don't know what notation you're using but it isn't the Matlab that I know where indices start at 1. If these are arbitrary sample indices then OK. But somehow you would need to resolve your time reference for the FFT so that phase is correct. Maybe you've done that and maybe not. I can't tell. As far as I know, most of the FFT programs take a real time sequence as input with the first sample of the sequence assumed to be at zero time. So, that's what I mean.... If you want to input for negative time (and because we are assuming the temporal sequence to be periodic and the sequence to be one period), then you put the negative time samples at the upper end of the sequence. So, your example here would look like: [0 1 2 3 4 3 2 1] *IF* by h[-4] you mean "the sample taken at time -4T" and -4T is on the time axis referenced to t=0 coinciding with h(0).
> > If we take for example cos(x), and we take a sequence from -pi to pi, it > will be an even sequence about x=0. But if we take x from -0.3*pi to 1.3*pi > (arbitrary multipliers), then this sequence will not be even. > > Am I going down a completely wrong line here?
***No you have it right I think. The issue is where in the FFT input sequence is the sample at t=0 located and is there any wrapping for samples taken at negative time?
> > You also mentioned "in FFT sense", do you mean there is a difference if I > consider DFT?
No. An FFT is an implementation of the DFT. Both terms mean a DFT from a mathematical point of view.
Thank you very much again Fred. 


>3) Not centered at t=0 but at T means that the sequence runs from [T - >(N-1)/2] to [T + (N-1)/2]. This could be an example of a causal >sequence where T is a positive number and >= (N-1)/2.
This point is very useful. Cleared quite a bit. Thank you.
>*Does that mean if they are positive that they can't be real??? :-(
I actually meant to say real or complex. Sorry for the mistake.
>***I don't know what notation you're using but it isn't the Matlab that >I know where indices start at 1. If these are arbitrary sample indices >then OK. But somehow you would need to resolve your time reference for >the FFT so that phase is correct. Maybe you've done that and maybe not. > I can't tell.
Sorry. They are supposed to be arbitrary sample indices. What I wanted to say was that, when we take a sequence of values it could be from 0 to (N-1) or (-N+3 to 2) or any other arbitrary range. But when we feed those values to a FFT routine, they it assumes the samples are from (-N/2 to N/2) or (0 to N-1) or a period therewith. But as you said, if the sequence is even in the range from [T -(N-1)/2] to [T + (N-1)/2], then I guess there is no ambiguity. Thank you so very much Fred. I think I have the basics down. Need to put those together in to one big picture now. Thank you very much for your time, effort and patience.
m26k9 wrote:
......................ell.
> > Sorry. They are supposed to be arbitrary sample indices. What I wanted to > say was that, when we take a sequence of values it could be from 0 to (N-1) > or (-N+3 to 2) or any other arbitrary range. But when we feed those values > to a FFT routine, they it assumes the samples are from (-N/2 to N/2) or (0 > to N-1) or a period therewith. But as you said, if the sequence is even in > the range from [T -(N-1)/2] to [T + (N-1)/2], then I guess there is no > ambiguity. >
***Well, there won't be any ambiguity if you consider a circular rotation that makes it even about the presumed zero-time sample before you do an FFT. ***Otherwise the result will be complex and you may be confused.The point of discussing indices was that a sequence *can* result in a real/even FFT but you have to index it properly. i.e. time shift it, circularly shift it first perhaps so that it goes to the FFT being even in time about t=0. If it's even about some other point then the FFT will be complex. That's often fine but if it's not what you expect then it could be a concern or a confusion factor.
> > Thank you so very much Fred. I think I have the basics down. Need to put > those together in to one big picture now. Thank you very much for your > time, effort and patience.
You're welcome!