Reply by Dirk Bell July 18, 20032003-07-18
Damn, I can't type.

In the preceding post:
   There should be a ')' after "computational load".
   "inconstant" should be "inconsistent".

I actually do speak English.

Dirk

Dirk A. Bell
DSP Consultant

"Dirk Bell" <dirkman@erols.com> wrote in message
news:bf98ri$r5t$1@bob.news.rcn.net...
> Rick, > > What I was commenting about was the Matlab script you posted right before
my
> response in the string of posts. By making the parameter changes I > suggested in your script, you can see that the complex filter method can > give you identical performance with the same # of taps (same computational > load. If you change the filter specs (stopband and passband is what you > changed) then ripple performance goes down requiring the increase in the > number of taps that you saw. So it appears that there isn't something > inherently more costly for the complex filter method vs hilbert transform > method for similar specs, but with inconstant filter specs between the two > methods you can make the complex filter method more costly. > > Some responses also mixed in with post below. > > Dirk > > "Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message > news:3f17f675.13586437@news.earthlink.net... > > On Wed, 16 Jul 2003 14:16:32 -0400, "Dirk Bell" <dirkman@erols.com> > > wrote: > > > > >Hi Rick, > > > > Hi Dirk, > > thanks for helpin' ! > > > > I wonder if I missed one of your posts, or something, > > because I'm having trouble understanding what you wrote. > > > > >You can design a complex filter that gives identical results > > > > "identical results" with what? > > Identical to Hilbert transformer method. > > > > > >and requires > > >the same computational complexity as using the Hilbert transformer as > > >follows: > > > > > >h(n)=d(n-Hilbert delay)+j*(Hilbert coefficients(n)); d() is discrete > > >impulse. > > > > As far as I can tell, your above scheme is what I did in > > my MATLAB code. > > Right, but I made the filtering effect in the compex filter method and > hilbert transform method > the same and got rid of the increased computational load. > > > > > >You can get identical results (off by phase factor of -j, not a
problem)
> by > > >designing a remez lowpass with > > > > > >F_pass = 0.4; % Filter's cutoff freq > > >F_stop = 0.6; % Beginning of stopband > > >NTaps=27; > > >(other parameters as you have them) > > > > > >and doing the mix as you have. > > > > Ah yes, I see what you're getting at. > > You want to reduce the complex filter's (the two > > real filters') passband ripple by making the passband > > more narrow. That's an idea. > > Narrower with respect to the filter you were trying, but the same as the > Hilbert > transformer. > > > > > > > >From there you can change the specs on the filter (you had changed > F_pass, > > >F_stop from what I have above; could also change error weights) and the > > >computations will go up as you saw. The real part will no longer have > only > > >one nonzero value. The alternating zeros will be present in both the
real
> > >and imaginary part. Worse case computational load should be twice that > of > > >the Hilbert transformer if you stick to the same filter size. > > > > Humm. What I'm seeing is that the complex filter method > > requires roughly eight times the computational workload of > > the Hilbert transfrmer method when the two methods have > > equivalent passband width and passband peak-peak ripple. > > When you ran my MATLAB code, did you see the same > > passband ripple characteristics that I've described. > > > > My goal is to see how the complex filter method compares with > > the FIR Hilbert method with respect to number of needed > > multiplies per output sample. It looks like you and I are > > seeing similar, but not exactly equal, results. > > > > I am trying to look at similar specifications to see if the difference is > really from the > different methods or from the different specifications. It appears to be > from the latter. > > > > > >Hope that helps. > > > > Thanks Dirk, > > [-Rick-] > > > >
Reply by Dirk Bell July 18, 20032003-07-18
Rick,

What I was commenting about was the Matlab script you posted right before my
response in the string of posts.  By making the parameter changes I
suggested in your script, you can see that the complex filter method can
give you identical performance with the same # of taps (same computational
load. If you change the filter specs (stopband and passband is what you
changed) then ripple performance goes down requiring the increase in the
number of taps that you saw. So it appears that there isn't something
inherently more costly for the complex filter method vs hilbert transform
method for similar specs, but with inconstant filter specs between the two
methods you can make the complex filter method more costly.

Some responses also mixed in with post below.

Dirk

"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message
news:3f17f675.13586437@news.earthlink.net...
> On Wed, 16 Jul 2003 14:16:32 -0400, "Dirk Bell" <dirkman@erols.com> > wrote: > > >Hi Rick, > > Hi Dirk, > thanks for helpin' ! > > I wonder if I missed one of your posts, or something, > because I'm having trouble understanding what you wrote. > > >You can design a complex filter that gives identical results > > "identical results" with what?
Identical to Hilbert transformer method.
> > >and requires > >the same computational complexity as using the Hilbert transformer as > >follows: > > > >h(n)=d(n-Hilbert delay)+j*(Hilbert coefficients(n)); d() is discrete > >impulse. > > As far as I can tell, your above scheme is what I did in > my MATLAB code.
Right, but I made the filtering effect in the compex filter method and hilbert transform method the same and got rid of the increased computational load.
> > >You can get identical results (off by phase factor of -j, not a problem)
by
> >designing a remez lowpass with > > > >F_pass = 0.4; % Filter's cutoff freq > >F_stop = 0.6; % Beginning of stopband > >NTaps=27; > >(other parameters as you have them) > > > >and doing the mix as you have. > > Ah yes, I see what you're getting at. > You want to reduce the complex filter's (the two > real filters') passband ripple by making the passband > more narrow. That's an idea.
Narrower with respect to the filter you were trying, but the same as the Hilbert transformer.
> > > >From there you can change the specs on the filter (you had changed
F_pass,
> >F_stop from what I have above; could also change error weights) and the > >computations will go up as you saw. The real part will no longer have
only
> >one nonzero value. The alternating zeros will be present in both the real > >and imaginary part. Worse case computational load should be twice that
of
> >the Hilbert transformer if you stick to the same filter size. > > Humm. What I'm seeing is that the complex filter method > requires roughly eight times the computational workload of > the Hilbert transfrmer method when the two methods have > equivalent passband width and passband peak-peak ripple. > When you ran my MATLAB code, did you see the same > passband ripple characteristics that I've described. > > My goal is to see how the complex filter method compares with > the FIR Hilbert method with respect to number of needed > multiplies per output sample. It looks like you and I are > seeing similar, but not exactly equal, results. >
I am trying to look at similar specifications to see if the difference is really from the different methods or from the different specifications. It appears to be from the latter.
> > >Hope that helps. > > Thanks Dirk, > [-Rick-] >
Reply by Rick Lyons July 18, 20032003-07-18
On Wed, 16 Jul 2003 14:16:32 -0400, "Dirk Bell" <dirkman@erols.com>
wrote:

>Hi Rick,
Hi Dirk, thanks for helpin' ! I wonder if I missed one of your posts, or something, because I'm having trouble understanding what you wrote.
>You can design a complex filter that gives identical results
"identical results" with what?
>and requires >the same computational complexity as using the Hilbert transformer as >follows: > >h(n)=d(n-Hilbert delay)+j*(Hilbert coefficients(n)); d() is discrete >impulse.
As far as I can tell, your above scheme is what I did in my MATLAB code.
>You can get identical results (off by phase factor of -j, not a problem) by >designing a remez lowpass with > >F_pass = 0.4; % Filter's cutoff freq >F_stop = 0.6; % Beginning of stopband >NTaps=27; >(other parameters as you have them) > >and doing the mix as you have.
Ah yes, I see what you're getting at. You want to reduce the complex filter's (the two real filters') passband ripple by making the passband more narrow. That's an idea.
>From there you can change the specs on the filter (you had changed F_pass, >F_stop from what I have above; could also change error weights) and the >computations will go up as you saw. The real part will no longer have only >one nonzero value. The alternating zeros will be present in both the real >and imaginary part. Worse case computational load should be twice that of >the Hilbert transformer if you stick to the same filter size.
Humm. What I'm seeing is that the complex filter method requires roughly eight times the computational workload of the Hilbert transfrmer method when the two methods have equivalent passband width and passband peak-peak ripple. When you ran my MATLAB code, did you see the same passband ripple characteristics that I've described. My goal is to see how the complex filter method compares with the FIR Hilbert method with respect to number of needed multiplies per output sample. It looks like you and I are seeing similar, but not exactly equal, results.
>Hope that helps.
Thanks Dirk, [-Rick-]
Reply by Rick Lyons July 18, 20032003-07-18
Thanks much Peter!
*Very interesting.*

I'll experiment with this when I get a chance.

Regards,
[-Rick-]

-----------------------------------------
On Wed, 16 Jul 2003 19:29:41 -0400, "Peter Brackett"
<ab4bc@ix.netcom.com> wrote:

>Rick: > >[snip] >> Hi Peter, >> Interesting. I've never used an IIR filter to implement a >> Hilbert transform. However, I've read that IIR Hilbert >> transformers don't yield the desired exact 90-degree phase >> shift. >[snip] > >You can approach 90-degrees to whatever degree of accuracy >you desire, and it can all be prescribed directly in terms of dB >of suppression of the unwanted negative [or positive] frequencies. > >i.e. the angle error becomes a dB error when you use filters to >create analytic signals rather than a classic Hilbert transformer. > >[snip] >> By the way, how do you go about translating a lowpass >> IIR filter's passband center frequency up to, say, Fs/4? >> >> Thanks, >> [-Rick-] >[snip] > >A simple rotation of the original filter's pole zero constellation >about the origin of the z-plane is all it takes to get the new >poles and zeros. Then just re-calculate >the z-polynomial coefficients from the new pole-zero >locations by multiplying them back out. > >The advantage is one heck of a lot fewer multiply >adds and memory locations required to create >the analytic signal when compared to using >the "classic" Hilbert transform. > >You can get extremely close to 90-degree separation >but genrerally the resulting relative phase angle >will be non-linear. as is true with all IIR filters when >compared to linear phase [symmetric] FIR filters. > >This phase non-linearity is easily corrected if >is necessary, and often it is just not necessary to have >linear phase, it is just necessary to have a 90-degree >phase difference, but if you need linear phase then >correct it, with an all-pass equalizer. > >-- >Peter >Consultant >Indialantic By-the-Sea, FL. > >
Reply by Peter Brackett July 16, 20032003-07-16
Rick:

[snip]
> Hi Peter, > Interesting. I've never used an IIR filter to implement a > Hilbert transform. However, I've read that IIR Hilbert > transformers don't yield the desired exact 90-degree phase > shift.
[snip] You can approach 90-degrees to whatever degree of accuracy you desire, and it can all be prescribed directly in terms of dB of suppression of the unwanted negative [or positive] frequencies. i.e. the angle error becomes a dB error when you use filters to create analytic signals rather than a classic Hilbert transformer. [snip]
> By the way, how do you go about translating a lowpass > IIR filter's passband center frequency up to, say, Fs/4? > > Thanks, > [-Rick-]
[snip] A simple rotation of the original filter's pole zero constellation about the origin of the z-plane is all it takes to get the new poles and zeros. Then just re-calculate the z-polynomial coefficients from the new pole-zero locations by multiplying them back out. The advantage is one heck of a lot fewer multiply adds and memory locations required to create the analytic signal when compared to using the "classic" Hilbert transform. You can get extremely close to 90-degree separation but genrerally the resulting relative phase angle will be non-linear. as is true with all IIR filters when compared to linear phase [symmetric] FIR filters. This phase non-linearity is easily corrected if is necessary, and often it is just not necessary to have linear phase, it is just necessary to have a 90-degree phase difference, but if you need linear phase then correct it, with an all-pass equalizer. -- Peter Consultant Indialantic By-the-Sea, FL.
Reply by Dirk Bell July 16, 20032003-07-16
Hi Rick,

You can design a complex filter that gives identical results and requires
the same computational complexity as using the Hilbert transformer as
follows:

h(n)=d(n-Hilbert delay)+j*(Hilbert coefficients(n)); d() is discrete
impulse.

You can get identical results (off by phase factor of -j, not a problem) by
designing a remez lowpass with

F_pass = 0.4; %  Filter's cutoff freq
F_stop = 0.6;  %  Beginning of stopband
NTaps=27;
(other parameters as you have them)

and doing the mix as you have.

From there you can change the specs on the filter (you had changed F_pass,
F_stop from what I have above; could also change error weights) and the
computations will go up as you saw.  The real part will no longer have only
one nonzero value. The alternating zeros will be present in both the real
and imaginary part.  Worse case computational load should be twice that of
the Hilbert transformer if you stick to the same filter size.

Hope that helps.

Dirk

Dirk A. Bell
DSP Consultant


"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message
news:3f154fcc.16660968@news.earthlink.net...
> On 15 Jul 2003 11:53:58 -0700, dirkman@erols.com (Dirk Bell) wrote: > > >Rick, > > > >Can you post your MATLAB filter design script? > > > >When you say 3-4 times more taps are you counting the half of the real > >and half of the imaginary taps that should be 0 after the mix? > > > >Dirk > > > > Hi Dirk, > yep the numbers I quoted include the zero-valued > coefficients. > > What I've found is that a Hilbert FIR filter of 27 coefficients > will have a magnitude peak-peak ripple of roughly 0.1 dB. > The two real filters (making up the single complex > filter used to generate an analytic signal) had to have > over 100 coefficients each to keep the difference in their > magnitude responses within 0.1 dB. > > If my modeling is correct, that 'complex filter' method > for generating an analytic signal, from a real signal, requires > about eight times as many multiplies as an equivalent single Hilbert > FIR filter!! > > Here's my MATLAB code: > > > clear > %%% Design a Hilbert transformer (FIR) > Ntaps = 27; % Number of taps in Hilbert FIR > B_Quad = remez(Ntaps-1,[.1 .9],[1,1],'hilbfilt'); > % Zero -out the coeffs that should be zero > B_Quad(abs(B_Quad)<0.00001) = 0; > > MagB = abs(fft(B_Quad,512)); > MagB = 20*log10(MagB/max(MagB)); > MagB(MagB<-1) = -1; % Threshold > figure(1), plot(MagB,'-b'), grid on, zoom on > xlabel('Freq'), ylabel('dB') > title('Mag of Hilb-FIR filter') > > > % Now design the complex FIR filter > % **** Design the lowpass FIR filter first ****** > F_pass = 0.4; % Filter's cutoff freq > F_stop = 0.45; % Beginning of stopband > F = [0,F_pass,F_stop ,1 ]; % Freq vector for remez > M = [1,1,0,0 ]; % Mag vector for remez > N_taps = 107; % Number of FIR filter taps > N = N_taps-1; > B_LP = remez(N,F,M); % Calc the lowpass filter's coeffs > > %B_LP = B_LP.*hanning(N_taps)'; % Window if you want. > %B_LP = 2*B_LP; % Gain compensation, if you want > > % **** Translate LP filter to a BP filter (complex) *** > Mix_Seq = exp(j*(pi/2)*(0:N_taps-1)); % complex expon. at Fs/4. > > B_BP = B_LP.*Mix_Seq(1:N_taps); % Freq translation. > B_Inphase = real(B_BP); % BP filter coeffs real parts > B_Quad = imag(B_BP); % BP filter coeffs imag parts > > MagReal = abs(fft(B_Inphase,512)); > MagImag = abs(fft(B_Quad,512)); > MagReal = 20*log10(MagReal/max(MagReal)); % Log ref at 0 dB. > MagImag = 20*log10(MagImag/max(MagImag)); > MagReal(MagReal<-1) = -1; % Threshold > MagImag(MagImag<-1) = -1; > figure(2), plot(MagReal,'-b'),hold on, plot(MagImag,'-r') > plot(MagReal-MagImag,'-k'), hold off, grid on, zoom on > title('Magnitudes: I filter-blue, Q filter-red, difference-black,') > xlabel('Freq'), ylabel('dB') > > > Thanks Dirk, > [-Rick-] >
Reply by Rick Lyons July 16, 20032003-07-16
On 15 Jul 2003 11:53:58 -0700, dirkman@erols.com (Dirk Bell) wrote:

>Rick, > >Can you post your MATLAB filter design script? > >When you say 3-4 times more taps are you counting the half of the real >and half of the imaginary taps that should be 0 after the mix? > >Dirk >
Hi Dirk, yep the numbers I quoted include the zero-valued coefficients. What I've found is that a Hilbert FIR filter of 27 coefficients will have a magnitude peak-peak ripple of roughly 0.1 dB. The two real filters (making up the single complex filter used to generate an analytic signal) had to have over 100 coefficients each to keep the difference in their magnitude responses within 0.1 dB. If my modeling is correct, that 'complex filter' method for generating an analytic signal, from a real signal, requires about eight times as many multiplies as an equivalent single Hilbert FIR filter!! Here's my MATLAB code: clear %%% Design a Hilbert transformer (FIR) Ntaps = 27; % Number of taps in Hilbert FIR B_Quad = remez(Ntaps-1,[.1 .9],[1,1],'hilbfilt'); % Zero -out the coeffs that should be zero B_Quad(abs(B_Quad)<0.00001) = 0; MagB = abs(fft(B_Quad,512)); MagB = 20*log10(MagB/max(MagB)); MagB(MagB<-1) = -1; % Threshold figure(1), plot(MagB,'-b'), grid on, zoom on xlabel('Freq'), ylabel('dB') title('Mag of Hilb-FIR filter') % Now design the complex FIR filter % **** Design the lowpass FIR filter first ****** F_pass = 0.4; % Filter's cutoff freq F_stop = 0.45; % Beginning of stopband F = [0,F_pass,F_stop ,1 ]; % Freq vector for remez M = [1,1,0,0 ]; % Mag vector for remez N_taps = 107; % Number of FIR filter taps N = N_taps-1; B_LP = remez(N,F,M); % Calc the lowpass filter's coeffs %B_LP = B_LP.*hanning(N_taps)'; % Window if you want. %B_LP = 2*B_LP; % Gain compensation, if you want % **** Translate LP filter to a BP filter (complex) *** Mix_Seq = exp(j*(pi/2)*(0:N_taps-1)); % complex expon. at Fs/4. B_BP = B_LP.*Mix_Seq(1:N_taps); % Freq translation. B_Inphase = real(B_BP); % BP filter coeffs real parts B_Quad = imag(B_BP); % BP filter coeffs imag parts MagReal = abs(fft(B_Inphase,512)); MagImag = abs(fft(B_Quad,512)); MagReal = 20*log10(MagReal/max(MagReal)); % Log ref at 0 dB. MagImag = 20*log10(MagImag/max(MagImag)); MagReal(MagReal<-1) = -1; % Threshold MagImag(MagImag<-1) = -1; figure(2), plot(MagReal,'-b'),hold on, plot(MagImag,'-r') plot(MagReal-MagImag,'-k'), hold off, grid on, zoom on title('Magnitudes: I filter-blue, Q filter-red, difference-black,') xlabel('Freq'), ylabel('dB') Thanks Dirk, [-Rick-]
Reply by Rick Lyons July 16, 20032003-07-16
On Wed, 16 Jul 2003 00:47:40 -0400, "Peter Brackett"
<ab4bc@ix.netcom.com> wrote:

>Rick: > >[snip] >"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message >news:3f135667.60818218@news.earthlink.net... >> Hi Guys, >: >: >> Another idea for generating an analytic signal, that's >> bounced around this newsgroup for quite a while, is >> designing a lowpass filter and translating its center >: >: >> If my modeling is correct, the complex-filter scheme for >> generating an analytic signal requires *many* more multiplies >> than the traditional FIR Hilbert method. >> >> Have any of you guys modeled these two methods and seen the >> same effects that I've seen? Have I screwed something up here? >[snip] > >I use this technique often, but I use IIR filters rather than FIR! > >It works really well with an IIR filter translated/rotated to place its' >transition band at the origin and the IIR filter consumes a lot fewer >multiply-adds and memory than either of the FIR [Hilbert >or Filter] techniques. > >A relatively simple low order IIR complex filter does a very efficient >job of separating positive frequencies from negative frequencies >and can be readily used to generate analytic signals to any prescribed >degree of "purity" [measured in dB of negative frequency suppression] >desired. > >-- >Peter >Consultant >Indialantic By-the-Sea, FL.
Hi Peter, Interesting. I've never used an IIR filter to implement a Hilbert transform. However, I've read that IIR Hilbert transformers don't yield the desired exact 90-degree phase shift. By the way, how do you go about translating a lowpass IIR filter's passband center frequency up to, say, Fs/4? Thanks, [-Rick-]
Reply by Peter Brackett July 16, 20032003-07-16
Rick:

[snip]
"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message
news:3f135667.60818218@news.earthlink.net...
> Hi Guys,
: :
> Another idea for generating an analytic signal, that's > bounced around this newsgroup for quite a while, is > designing a lowpass filter and translating its center
: :
> If my modeling is correct, the complex-filter scheme for > generating an analytic signal requires *many* more multiplies > than the traditional FIR Hilbert method. > > Have any of you guys modeled these two methods and seen the > same effects that I've seen? Have I screwed something up here?
[snip] I use this technique often, but I use IIR filters rather than FIR! It works really well with an IIR filter translated/rotated to place its' transition band at the origin and the IIR filter consumes a lot fewer multiply-adds and memory than either of the FIR [Hilbert or Filter] techniques. A relatively simple low order IIR complex filter does a very efficient job of separating positive frequencies from negative frequencies and can be readily used to generate analytic signals to any prescribed degree of "purity" [measured in dB of negative frequency suppression] desired. -- Peter Consultant Indialantic By-the-Sea, FL.
Reply by Dirk Bell July 15, 20032003-07-15
Rick,

Can you post your MATLAB filter design script?

When you say 3-4 times more taps are you counting the half of the real
and half of the imaginary taps that should be 0 after the mix?

Dirk

Dirk Bell

ricklyon@REMOVE.onemain.com (Rick Lyons) wrote in message news:<3f13fc8e.103352734@news.earthlink.net>...
> On Tue, 15 Jul 2003 01:18:27 GMT, ricklyon@REMOVE.onemain.com (Rick > Lyons) wrote: > > Hi Guys, > > Shoot! I didn't explain myself properly. > > Here's what I wrote: > > > >Here's what I've seen: The passband magnitude response ripple > >using a remez-designed FIR Hilbert filter (floating point > >numbers) having around 30 taps is roughly 0.1 dB peak-peak. > >To get that same peak-peak passband ripple using the > >complex filter scheme seems to require 3-4 times as many taps!! > > > That last sentence should have said: > > To get that same peak-peak passband ripple *difference* > between the two real filters using the > complex filter scheme seems to require 3-4 times as many taps > in each filter!! > > If my modeling is correct, the complex-filter scheme for > generating an analytic signal requires *many* more multiplies > than the traditional single-FIR-filter Hilbert method. > > Thanks, > [-Rick-] > > > >