DSPRelated.com
Forums

two kinds of average filtering; exponential average VS modified moving average

Started by Simon March 20, 2006
1.  exponential average. (some kind of one order IIR filter)
according to RC filtering
and moving average.
,we can get the exponential average equ:
yk=fs/(fs+2*pi*1.5*fc)*y(k-1)+(2*pi*1.5*fc/(fs+2*pi*1.5*fc))*xk
---yk, the current output
---fs,  sampling frequency
---fc,  the low pass filter (RC filter) cutoff frequency 1.5*fc to make
it in the passband for pratical caclulation.

advantage: easy to be implemtated and need few RAM
Disadvantage:  can not smooth the abrupt noise that its frequency is
more then fs/2.


2. modified moving average (some kind of modified FIR filter)
    when we get 4 or more latest value x(k-3) x(k-2) x(k-1) x(k)
   we get the temp1=max(x(k-3), x(k-2), x(k-1), x(k) )
                   temp2=min(x(k-3), x(k-2), x(k-1), x(k) )
                   temp3=sum(x(k-3), x(k-2), x(k-1), x(k) )
   then y(k)=(Tem3-Temp1-Temp2)/2

   advantage: can kick off the abrupt noise that its frequency is more
then fs/2
   disadvantage: need more RAM for better smooth effect.

my question is:
 1.     Due to the disadvatage of exponential averaging, Is it a must
that the pre-analog low pass filter circuits should kick off the signal
with frequency more than fs/2? But sometimes, you know, because of the
noise of the power for op of the analog low pass filter, it is too hard
to kick off this kind of noise derived from power supply, frequently
high frequency.

2.      How do you think the modified moving average?

3.   when to use and not use these two kinds of filter algorithm?

thanks

Simon says <sorry, I couldn't resist>:
> [...] > 2. How do you think the modified moving average?
This sounds like English, but there are many doubts as to its meaning. Are you asking: 1. What do you think of the modified moving average? 2. How do you implement the modified moving average? 3. What is the sexual orientation of the modified moving average? Perhaps we can answer your questions if we know what they are. -- % Randy Yates % "My Shangri-la has gone away, fading like %% Fuquay-Varina, NC % the Beatles on 'Hey Jude'" %%% 919-577-9882 % %%%% <yates@ieee.org> % 'Shangri-La', *A New World Record*, ELO http://home.earthlink.net/~yatescr
Simon wrote:
> 1. exponential average. (some kind of one order IIR filter) > according to RC filtering > and moving average. > ,we can get the exponential average equ: > yk=fs/(fs+2*pi*1.5*fc)*y(k-1)+(2*pi*1.5*fc/(fs+2*pi*1.5*fc))*xk > ---yk, the current output > ---fs, sampling frequency > ---fc, the low pass filter (RC filter) cutoff frequency 1.5*fc to make > it in the passband for pratical caclulation. > > advantage: easy to be implemtated and need few RAM > Disadvantage: can not smooth the abrupt noise that its frequency is > more then fs/2.
Stop right there. After the signal has been sampled, there are no frequencies above Fs/2. Any components originally above it have been reflected below. Moving-average filters are low-pass filters. Depending on the implementation and on what "good" means, better ones can be made with the same computational effort. What does "modified" mean to you? 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;
:)
Thanks for your comment. It's some kind of Tech English with mixed
features of the chinese, matlab, C and some like language. Just a joke.


Ok, I will explain what is so called "modified moving average filter".

The standard moving average filter is: for example, we get the latest
sampling data,
x(k-3) x(k-2) x(k-1) x(k), then the output value is yk=
[x(k-3)+x(k-2)+x(k-1)+x(k)]/4.
But for the modifide moving average filter. :there are four step.
       step 1:  got the latest 4 sampling data. x(k-3) x(k-2) x(k-1)
x(k)
       step 2:  find out the maximum value among these four sampling
data, max( )  and the minimum value ,min()
  step3:   meantime, calulate the sum of these four value that is,
sum=x(k-3)+x(k-2)+x(k-1).+xk
 step4.   then the output value yk=[sum-max()-min()]/2

Hope you understand my idea now.
I just want to know which is better, the exponential and this modified
one?

Simon wrote:
> :) > Thanks for your comment. It's some kind of Tech English with mixed > features of the chinese, matlab, C and some like language. Just a joke. > > > Ok, I will explain what is so called "modified moving average filter". > > The standard moving average filter is: for example, we get the latest > sampling data, > x(k-3) x(k-2) x(k-1) x(k), then the output value is yk= > [x(k-3)+x(k-2)+x(k-1)+x(k)]/4. > But for the modifide moving average filter. :there are four step. > step 1: got the latest 4 sampling data. x(k-3) x(k-2) x(k-1) > x(k) > step 2: find out the maximum value among these four sampling > data, max( ) and the minimum value ,min() > step3: meantime, calulate the sum of these four value that is, > sum=x(k-3)+x(k-2)+x(k-1).+xk > step4. then the output value yk=[sum-max()-min()]/2 > > Hope you understand my idea now. > I just want to know which is better, the exponential and this modified > one?
Better in what way? You haven't told us that. I'm sure you realize that [sum-max()-min()]/2 is simply the average of the two middle data. With three points, it is identical to a median filter. How did you come to consider it? 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;
Thanks Jerry. It should  be called "modified median filter" or some
correct term.
well, Better in the effect, meantime with less needed RAM resource.
for example.
I use TMS320LF2407  to do the data sampling, and then do some low pass
Filtering, then Do the transform (constant Q transform) to anlyze the
spectrogram. The sampling frequency is 10KHZ. Now, I need some kind of
digital low pass filter. The cutoff frequency is about 900HZ. But
because my power supply for AD is not so clean, there may be some
noise, its frequency is about 1MHZ (I saw it through the OSC).
(1MHZ>fs/2).
  Then what kind of filtering ways you prefer, exponential average or
the modified median filter or some filter else?

"Simon" <Simon.jwfg@gmail.com> writes:

> :) > Thanks for your comment. It's some kind of Tech English with mixed > features of the chinese, matlab, C and some like language. Just a joke. > > > Ok, I will explain what is so called "modified moving average filter". > > The standard moving average filter is: for example, we get the latest > sampling data, > x(k-3) x(k-2) x(k-1) x(k), then the output value is yk= > [x(k-3)+x(k-2)+x(k-1)+x(k)]/4. > But for the modifide moving average filter. :there are four step. > step 1: got the latest 4 sampling data. x(k-3) x(k-2) x(k-1) > x(k) > step 2: find out the maximum value among these four sampling > data, max( ) and the minimum value ,min() > step3: meantime, calulate the sum of these four value that is, > sum=x(k-3)+x(k-2)+x(k-1).+xk > step4. then the output value yk=[sum-max()-min()]/2 > > Hope you understand my idea now. > I just want to know which is better, the exponential and this modified > one?
I've never heard of such a filter, and I don't see the utility in it. It is non-linear, so it can't be analyzed using standard techniques like the z-transform. -- % Randy Yates % "Though you ride on the wheels of tomorrow, %% Fuquay-Varina, NC % you still wander the fields of your %%% 919-577-9882 % sorrow." %%%% <yates@ieee.org> % '21st Century Man', *Time*, ELO http://home.earthlink.net/~yatescr
Randy Yates said the following on 21/03/2006 10:55:
>> >> Hope you understand my idea now. >> I just want to know which is better, the exponential and this modified >> one? > > I've never heard of such a filter, and I don't see the utility in it. It > is non-linear, so it can't be analyzed using standard techniques like the > z-transform.
Non-linear filters do have their uses, e.g. a median filter is commonly used to remove "impulse noise" (also known as "salt-and-pepper noise") from images. -- Oli
Simon wrote:
> Thanks Jerry. It should be called "modified median filter" or some > correct term. > well, Better in the effect, meantime with less needed RAM resource. > for example. > I use TMS320LF2407 to do the data sampling, and then do some low pass > Filtering, then Do the transform (constant Q transform) to anlyze the > spectrogram. The sampling frequency is 10KHZ. Now, I need some kind of > digital low pass filter. The cutoff frequency is about 900HZ. But > because my power supply for AD is not so clean, there may be some > noise, its frequency is about 1MHZ (I saw it through the OSC). > (1MHZ>fs/2). > Then what kind of filtering ways you prefer, exponential average or > the modified median filter or some filter else?
You have to get rid of the noise /before/ it's sampled. The noise isn't coming through the filter, it's getting into the electronics through the power leads. Bypass the supply with good low-impedance capacitors. That means using ceramics for high frequencies in parallel with the 'lytics that are only good for lower frequencies. Make sure the analog ground is connected with a loop. No amount of digital processing will correct a signal that is corrupted by noise outside the signal path. I repeat: once the signal is sampled at 10 KHz, *all* of its components are below 5 KHz. No matter what frequency they started at, sampling put them there. After sampling, it's too late to filter. 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 should have written:


> ... Make sure the analog ground is > connected withOUT a loop. ...
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;