DSPRelated.com
Forums

FIR gain

Started by Philip Newman May 8, 2004
I have an FIR filter with the system equation y[n] =
0.25x[n]+0.5x[n-1]+0.25x[n-2] which gives an impulse response of h = [0.25
0.5 0.25]

without resorting to Z-transform analysis, how can I work out the gain of
the filter at DC and at the half nyquist frequency?

I think the gain of the filter at DC is the sum of the impulse response, in
this case 1.  but what about the half-nyquist?

I can think of it as a series of the impulse input, [1 0 0 0 0 ...] and then
stepping through every other one (ie half) and summing that?

I'm not sure how I am supposed to do this,

If anyone can help, please let me know

cheers

Phil


Philip Newman wrote:
> I have an FIR filter with the system equation y[n] = > 0.25x[n]+0.5x[n-1]+0.25x[n-2] which gives an impulse response of h = [0.25 > 0.5 0.25] > > without resorting to Z-transform analysis, how can I work out the gain of > the filter at DC and at the half nyquist frequency?
Why avoid Z-Transform analysis? It makes everything so easy. At the risk of being a jerk; I am not going to answer your question directly, since it looks like homework. I'll answer something close. You need to figure it out on your own. Lets say that your equation was y[n] = .3x[n] -.7x[n-1] + .5x[n-2] + .1x[n-3] Recall that Z = exp(j*w), which implies Z^-k = exp(-j*w*k). Each delay represents another power of Z So H(z) = .3 Z^0 - .7 Z^-1 + .5 Z^-2 + .1 Z^-3 @ w=0 (DC), Z = exp(j*0) = 1 H(1) = .3 -.7*1 +.5*1^-2 + .1*1^-3 = 1 @ w = pi/4 Z = exp(j*pi/4) = .707 + .707 j H(j) = ... = -0.265685 + -0.075736i gain, |H(j)| = .27627 I hope this helps, Mark
Philip Newman wrote:

> I have an FIR filter with the system equation y[n] = > 0.25x[n]+0.5x[n-1]+0.25x[n-2] which gives an impulse response of h = [0.25 > 0.5 0.25] > > without resorting to Z-transform analysis, how can I work out the gain of > the filter at DC and at the half nyquist frequency? > > I think the gain of the filter at DC is the sum of the impulse response, in > this case 1. but what about the half-nyquist?
You could do exactly what you did to obtain the DC: you simulated a DC input and computed the output. So, just imagine an input at half the Nyquist rate (which, BTW, is outside the legal discrete-time domain range). It would look like -1 +1 -1 +1. As you can see, the output is zero. So, your gain at half the Nyquist rate is zero. (again, notice that this is thin ice -- you can not have a sinusoidal signal sampled at exactly half its frequency, which is what I did -- for that matter, one possible sampling would be all zeros). But it sort of makes sense in that you're evaluating the highest possible frequency you can get from the discrete-time signal you have. So it does correspond to the limit as you approach the Nyquist frequency. You could have easily verified this formally by computing the transfer function: H(z) = 0.25 + 0.5 z^-1 + 0.25 z^-2 Evaluate the transfer function at z = 1 (for DC) and at z = -1 for half-Nyquist. HTH, Carlos --
"Carlos Moreno" <moreno_at_mochima_dot_com@xx.xxx> wrote in message
news:foanc.111862$207.1520589@wagner.videotron.net...
> Philip Newman wrote: > > > I have an FIR filter with the system equation y[n] = > > 0.25x[n]+0.5x[n-1]+0.25x[n-2] which gives an impulse response of h =
[0.25
> > 0.5 0.25] > > > > without resorting to Z-transform analysis, how can I work out the gain
of
> > the filter at DC and at the half nyquist frequency? > > > > I think the gain of the filter at DC is the sum of the impulse response,
in
> > this case 1. but what about the half-nyquist? > > You could do exactly what you did to obtain the DC: you simulated > a DC input and computed the output. > > So, just imagine an input at half the Nyquist rate (which, BTW, is > outside the legal discrete-time domain range). It would look like > -1 +1 -1 +1. As you can see, the output is zero. So, your gain > at half the Nyquist rate is zero. (again, notice that this is thin > ice -- you can not have a sinusoidal signal sampled at exactly half > its frequency, which is what I did -- for that matter, one possible > sampling would be all zeros). But it sort of makes sense in that > you're evaluating the highest possible frequency you can get from > the discrete-time signal you have. So it does correspond to the > limit as you approach the Nyquist frequency. > > You could have easily verified this formally by computing the transfer > function: H(z) = 0.25 + 0.5 z^-1 + 0.25 z^-2 > > Evaluate the transfer function at z = 1 (for DC) and at z = -1 > for half-Nyquist. > > HTH, > > Carlos > --
thats a great help, thanks. I usually work it out by putting z = exp(j2*pi*f*T) and then setting f = 0 for DC, and f = fs/2 and T = 1/fs for the half nyquist, but in this case I can't convert to Z-domain... Phil
Philip Newman wrote:

> I have an FIR filter with the system equation y[n] = > 0.25x[n]+0.5x[n-1]+0.25x[n-2] which gives an impulse response of h = [0.25 > 0.5 0.25] > > without resorting to Z-transform analysis, how can I work out the gain of > the filter at DC and at the half nyquist frequency? > > I think the gain of the filter at DC is the sum of the impulse response, in > this case 1. but what about the half-nyquist? > > I can think of it as a series of the impulse input, [1 0 0 0 0 ...] and then > stepping through every other one (ie half) and summing that? > > I'm not sure how I am supposed to do this, > > If anyone can help, please let me know > > cheers > > Phil
The gain at DC is easy: the sum of the coefficients, in your case, one. People throw "Nyquist frequency" around sloppily. Do you mean the sampling rate, or half of it? At f = Fs/2 (the simpler case), there are two samples per cycle. Assume a cosine, so the first sample is 1, the second, -1, and the third, 1. Multiplying by the coefficients and adding, the result is 0. Check again 90 degrees away. With a sine, the samples are all 0; again the result is 0; that's the response. If by half Nyquist you mean Fs/4, there are 4 cycles per sample. In that case, again using a cosine, the samples will be 1, 0, -1. Again, the result is zero. With a sin, the samples are 0, 1, 0. The result is .5. The response is the geometric mean of the cos result and the sin result. The filter's attenuation is 6 dB. The coefficients describe a binomial filter. The class has interesting properties, not the least of which is being intuitive. They make decent but hardly optimum low-passes. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins wrote:

> At f = Fs/2 (the simpler case), there are two samples per cycle. Assume > a cosine, so the first sample is 1, the second, -1, and the third, 1. > Multiplying by the coefficients and adding, the result is 0. Check again > 90 degrees away. With a sine, the samples are all 0; again the result is > 0; that's the response.
Careful -- see my other message. Notice that f = Fs/2 is outside the valid range for reconstruction to be possible (the sampling frequency must be *greater than* the bandwidth -- not greater than or equal, but strictly greater than). A sine is precisely the example to illustrate this -- all samples are 0, which can represent two different signals: a sine at Fs/2, and the signal x(t) = 0 (actually, it can represent only one signal that meets the bandwith requirements, plus an infinity of signals outside the range -- a sine at Fs/2 is just one of them) Carlos --
Carlos Moreno wrote:

> Jerry Avins wrote: > >> At f = Fs/2 (the simpler case), there are two samples per cycle. >> Assume a cosine, so the first sample is 1, the second, -1, and the >> third, 1. Multiplying by the coefficients and adding, the result is 0. >> Check again 90 degrees away. With a sine, the samples are all 0; again >> the result is 0; that's the response. > > > Careful -- see my other message. Notice that f = Fs/2 is outside the > valid range for reconstruction to be possible (the sampling frequency > must be *greater than* the bandwidth -- not greater than or equal, but > strictly greater than). A sine is precisely the example to illustrate > this -- all samples are 0, which can represent two different signals: > a sine at Fs/2, and the signal x(t) = 0 (actually, it can represent > only one signal that meets the bandwith requirements, plus an infinity > of signals outside the range -- a sine at Fs/2 is just one of them) > > Carlos > --
In this case, reconstruction is not an issue because the gain is zero. A frequency lower than Fs/2 can be accurately reconstructed. A frequency higher than Fs/2 is pernicious; it contaminates those below by aliasing. Fs/2 itself is borderline; it cannot be accurately reconstructed (although an attempted reconstruction will not exceed the true value), but is does not contaminate. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins wrote:

> Carlos Moreno wrote: > >> Jerry Avins wrote: >> >>> At f = Fs/2 (the simpler case), there are two samples per cycle. >>> Assume a cosine, so the first sample is 1, the second, -1, and the >>> third, 1. Multiplying by the coefficients and adding, the result is >>> 0. Check again 90 degrees away. With a sine, the samples are all 0; >>> again the result is 0; that's the response. >> >> Careful -- see my other message. Notice that f = Fs/2 is outside the >> valid range for reconstruction to be possible (the sampling frequency >> must be *greater than* the bandwidth -- not greater than or equal, but >> strictly greater than). A sine is precisely the example to illustrate >> this -- all samples are 0, which can represent two different signals: >> a sine at Fs/2, and the signal x(t) = 0 (actually, it can represent >> only one signal that meets the bandwith requirements, plus an infinity >> of signals outside the range -- a sine at Fs/2 is just one of them) >> > > In this case, reconstruction is not an issue because the gain is zero.
Of course it is an issue. I mean, the gain in the discrete-time domain should correspond to the gain in the continuous-time domain, right? Well, I could claim that the output of your filter is not zero, but it is a sine wave of amplitude 2000 -- so, in my version, the gain is indeed 2000. I mean, the fact that the gain is zero is just a detail. Imagine applying the same analysis to a high-pass filter -- say, something like y(n) = x(n) - x(n-1). In this case, plugging an input that is a sine or a cosine (at Fs/2) gives you completely different outputs. The reason is that the signals being represented are not valid -- if we allow the ferquency to be *equal to* half the sampling rate, then there is an infinity of signals that could be repersented (in all cases): for 0,0,0,0... any signal of the form A*sin(wt) (for the right value of w) gives you that sampled version. For a signal of the form -A, A, -A, A, .... , there is also an infinity of signals -- either A*cos(wt), or A'*cos(wt+phi) (for every value of A, and every value of phi in (-pi,pi), there is a value of A' such that the samples of the function A'cos(wt+phi) are ... -A, A, -A, A, .... )
> A frequency lower than Fs/2 can be accurately reconstructed. A frequency > higher than Fs/2 is pernicious; it contaminates those below by aliasing. > Fs/2 itself is borderline; it cannot be accurately reconstructed > (although an attempted reconstruction will not exceed the true value),
I think this statement between parenthesis is incorrect -- the example in my previous paragraph is precisely a counter-example to it, right? (unless I did not understand what you mean by "exceed the true value"?) My point is, more generally speaking, that the sampling theorem specifies that a signal can be exactly and unambiguously reconstructed from samples at a rate of Fs if and only if the bandwidth of the signal is *less than* Fs/2. So, an example of a signal that corresponds to the sampled version of a sinusoid at exactly Fs/2 is ill-formed, since the process of sampling such signal violates the sampling theorem. Carlos --
Carlos Moreno wrote:

> Jerry Avins wrote: > >> Carlos Moreno wrote: >> >>> Jerry Avins wrote: >>> >>>> At f = Fs/2 (the simpler case), there are two samples per cycle. >>>> Assume a cosine, so the first sample is 1, the second, -1, and the >>>> third, 1. Multiplying by the coefficients and adding, the result is >>>> 0. Check again 90 degrees away. With a sine, the samples are all 0; >>>> again the result is 0; that's the response. >>> >>> >>> Careful -- see my other message. Notice that f = Fs/2 is outside the >>> valid range for reconstruction to be possible (the sampling frequency >>> must be *greater than* the bandwidth -- not greater than or equal, but >>> strictly greater than). A sine is precisely the example to illustrate >>> this -- all samples are 0, which can represent two different signals: >>> a sine at Fs/2, and the signal x(t) = 0 (actually, it can represent >>> only one signal that meets the bandwith requirements, plus an infinity >>> of signals outside the range -- a sine at Fs/2 is just one of them) >>> >> >> In this case, reconstruction is not an issue because the gain is zero. > > > Of course it is an issue. I mean, the gain in the discrete-time > domain should correspond to the gain in the continuous-time domain, > right? Well, I could claim that the output of your filter is not > zero, but it is a sine wave of amplitude 2000 -- so, in my version, > the gain is indeed 2000.
Sample a signal of magnitude 1 at exactly Fs/2 at a sequence of phases, starting with a cosine whose second harmonic is in phase with the sampling clock, and ending with a sine, 90 degrees advanced. For the cosine, samples are taken at at the positive and negative peaks, and the reconstructed amplitude will be correct. For other phases, the reconstructed amplitude will be less than 1, and for the sine, it will be 0. In the filter described, an order 2 binomial, the gain at Fs/2 is zero. To claim that it exceeds unity is just silly. I'm sure you have something in mind, but I can't guess what.
> I mean, the fact that the gain is zero is just a detail.
A detail to be sure, but it means that however large the input, there will be no output. Where does A=2000 come from.
> Imagine > applying the same analysis to a high-pass filter -- say, something > like y(n) = x(n) - x(n-1). In this case, plugging an input that > is a sine or a cosine (at Fs/2) gives you completely different > outputs.
To find the gain, input one of each, then take Sqrt(sinresponse^2 + cosresponse^2) of the two results. It works every time, with all FIR filters at all frequencies. I think I earlier wrote geometric mean. If so, this is a correction.
> The reason is that the signals being represented are > not valid -- if we allow the ferquency to be *equal to* half the > sampling rate, then there is an infinity of signals that could be > repersented (in all cases): for 0,0,0,0... any signal of the > form A*sin(wt) (for the right value of w) gives you that sampled > version. For a signal of the form -A, A, -A, A, .... , there is > also an infinity of signals -- either A*cos(wt), or A'*cos(wt+phi)
Sqrt(sinresponse^2 + cosresponse^2) works. Try it.
> (for every value of A, and every value of phi in (-pi,pi), there > is a value of A' such that the samples of the function A'cos(wt+phi) > are ... -A, A, -A, A, .... ) > > >> A frequency lower than Fs/2 can be accurately reconstructed. A frequency >> higher than Fs/2 is pernicious; it contaminates those below by aliasing. >> Fs/2 itself is borderline; it cannot be accurately reconstructed >> (although an attempted reconstruction will not exceed the true value), > > > I think this statement between parenthesis is incorrect -- the > example in my previous paragraph is precisely a counter-example to > it, right? (unless I did not understand what you mean by "exceed > the true value"?)
The reconstructed amplitude cannot exceed the amplitude of the sampled signal.
> My point is, more generally speaking, that the sampling theorem > specifies that a signal can be exactly and unambiguously reconstructed > from samples at a rate of Fs if and only if the bandwidth of the > signal is *less than* Fs/2. So, an example of a signal that > corresponds to the sampled version of a sinusoid at exactly Fs/2 > is ill-formed, since the process of sampling such signal violates > the sampling theorem.
That is correct. Such a signal cannot be accurately reconstructed The second harmonic of reconstruction of a signal at Fs/2 will always be in phase with the sampling clock and the amplitude may be too small. If the original signal is A*cos(Fs*t/2) + B*sin(Fs*t/2), then the inaccurate reconstruction consists of A*cos(Fs*t/2) alone. That's wrong, but not pernicious. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;

Carlos Moreno wrote:

> Of course it is an issue. I mean, the gain in the discrete-time > domain should correspond to the gain in the continuous-time domain, > right? Well, I could claim that the output of your filter is not > zero, but it is a sine wave of amplitude 2000 -- so, in my version, > the gain is indeed 2000.
so if you have a discrete series of numbers ... 1 -1 1 -1 1 -1 .... and you feed that to the filter [1 2 1]/4 you say the gain is 2000 because of some mumbo jumbo about sampling theorem. Regardless of what you imagine that signal might represent the process of convolving will still always give you the same answer. The gain is zero and the output of the filter will be a stream of zeroes. -jim -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =-----