Moving Average for Notch filtering
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a periodic signal(ECG) with period of ~1 seconds. It does not have features that are shorter than 0.04 seconds. For removal of 60Hz, I thought instead of implementing a notch filter, doing a simple moving average of 1/60~0.016 seconds.(Averaging over a larger window might destroy signal information, and also it's not needed) This is much simpler than a notch filter which can be of several orders. Am I missing something?
filters moving-average
add a comment |Â
up vote
1
down vote
favorite
I have a periodic signal(ECG) with period of ~1 seconds. It does not have features that are shorter than 0.04 seconds. For removal of 60Hz, I thought instead of implementing a notch filter, doing a simple moving average of 1/60~0.016 seconds.(Averaging over a larger window might destroy signal information, and also it's not needed) This is much simpler than a notch filter which can be of several orders. Am I missing something?
filters moving-average
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a periodic signal(ECG) with period of ~1 seconds. It does not have features that are shorter than 0.04 seconds. For removal of 60Hz, I thought instead of implementing a notch filter, doing a simple moving average of 1/60~0.016 seconds.(Averaging over a larger window might destroy signal information, and also it's not needed) This is much simpler than a notch filter which can be of several orders. Am I missing something?
filters moving-average
I have a periodic signal(ECG) with period of ~1 seconds. It does not have features that are shorter than 0.04 seconds. For removal of 60Hz, I thought instead of implementing a notch filter, doing a simple moving average of 1/60~0.016 seconds.(Averaging over a larger window might destroy signal information, and also it's not needed) This is much simpler than a notch filter which can be of several orders. Am I missing something?
filters moving-average
filters moving-average
asked 1 hour ago
Learner
1296
1296
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago
add a comment |Â
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
No you are not missing anything. A moving average with a period of $T = 1/60$ seconds will indeed have a notch at 60 Hz, since the frequency response is a Sinc function with the first null at 1/T. (So it is both a low pass filter with an magnitude envelope that goes down as 1/f combined with a notches at integers of 1/T not including 0).
This is because a moving average has an impulse response that is a rectangular function of duration T, and the Fourier Transform of such a function is a Sinc (and the Fourier Transform of the Impulse Response is the Frequency Response). Digital Filters are similarly formed when the impulse response is a sampled rectangular function and thus their Fourier Transform will approach a Sinc function (what I like to refer as an "aliased" Sinc function similar to other aliasing in discrete time systems). If we position the sampling rate at integer multiples of 60 Hz, The null will be at 60 Hz and it's higher harmonics if the digital impulse response (formally called the unit sample response) is uniform samples for T duration, where T is 1/60 Hz (which is a moving average). Therefore the minimum sampling rate to do this digitally would be 120 Hz, otherwise 180 Hz, 240 Hz, etc.). Note that I said this would approach a Sinc function; notice the plots below of the actual frequency responses for each choice of sampling rate when we position the null at 60 Hz and do the moving average:
2 point moving average, sampling rate = 120 Hz
3 point moving average with sampling rate = 180 Hz
4 point moving average with sampling rate = 240 Hz
Also what you could alternatively consider which is even simpler is a "comb filter" structure which is simply the addition of the input with a delayed version of itself where the delay is equal to T/2.
This will have the frequency response according to:
$$H(omega) = 1 + e^jomega T/2$$
Since the Fourier Transform of a delay is given as
$$x(t) = delta(t-T) <==> x(omega) = e^-jomega T$$
With the magnitude plotted below:
This is equivalent to the digital filter with a delay of one sample when the sampling rate is 120 Hz, and a transfer function given as:
$$H(z) = 1+z^-1$$
with the frequency response when z is the unit circle as
$$H(e^jomega) = 1 + e^-jomega$$
with $omega$ going from 0 to $2pi$ in this case representing the normalized freq from 0 to the sampling rate.
If you are concerned about the "frequency droop" in your passband area for either of the above two solutions, you could consider using this very simple three tap FIR compensator described at this link for an elegant yet simple notch filter solution:
how to make CIC compensation filter
And here is a digital notch filter that I would typically implement when a very tight notch is required with a flat passband, to compare to the approaches above (and does not have the same limitations on sampling rates that can be used):
Transfer function of second order notch filter
add a comment |Â
up vote
1
down vote
A moving average is always a low pass filter, you are never going to get a notch at your desired frequency. You technically might be able to design it just right to have a notch at 60Hz, but you'll have notches at other frequencies. Also while the period of your signal may be 1 second, I suspect it will have higher frequency components.
Type this into matlab/octave with any number of N you'll find it is always a low pass.
N = 80
freqz(ones(1,N) * 1/N, 1)
A moving average is just a filter where all the coefficients are 1/N.
New contributor
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
No you are not missing anything. A moving average with a period of $T = 1/60$ seconds will indeed have a notch at 60 Hz, since the frequency response is a Sinc function with the first null at 1/T. (So it is both a low pass filter with an magnitude envelope that goes down as 1/f combined with a notches at integers of 1/T not including 0).
This is because a moving average has an impulse response that is a rectangular function of duration T, and the Fourier Transform of such a function is a Sinc (and the Fourier Transform of the Impulse Response is the Frequency Response). Digital Filters are similarly formed when the impulse response is a sampled rectangular function and thus their Fourier Transform will approach a Sinc function (what I like to refer as an "aliased" Sinc function similar to other aliasing in discrete time systems). If we position the sampling rate at integer multiples of 60 Hz, The null will be at 60 Hz and it's higher harmonics if the digital impulse response (formally called the unit sample response) is uniform samples for T duration, where T is 1/60 Hz (which is a moving average). Therefore the minimum sampling rate to do this digitally would be 120 Hz, otherwise 180 Hz, 240 Hz, etc.). Note that I said this would approach a Sinc function; notice the plots below of the actual frequency responses for each choice of sampling rate when we position the null at 60 Hz and do the moving average:
2 point moving average, sampling rate = 120 Hz
3 point moving average with sampling rate = 180 Hz
4 point moving average with sampling rate = 240 Hz
Also what you could alternatively consider which is even simpler is a "comb filter" structure which is simply the addition of the input with a delayed version of itself where the delay is equal to T/2.
This will have the frequency response according to:
$$H(omega) = 1 + e^jomega T/2$$
Since the Fourier Transform of a delay is given as
$$x(t) = delta(t-T) <==> x(omega) = e^-jomega T$$
With the magnitude plotted below:
This is equivalent to the digital filter with a delay of one sample when the sampling rate is 120 Hz, and a transfer function given as:
$$H(z) = 1+z^-1$$
with the frequency response when z is the unit circle as
$$H(e^jomega) = 1 + e^-jomega$$
with $omega$ going from 0 to $2pi$ in this case representing the normalized freq from 0 to the sampling rate.
If you are concerned about the "frequency droop" in your passband area for either of the above two solutions, you could consider using this very simple three tap FIR compensator described at this link for an elegant yet simple notch filter solution:
how to make CIC compensation filter
And here is a digital notch filter that I would typically implement when a very tight notch is required with a flat passband, to compare to the approaches above (and does not have the same limitations on sampling rates that can be used):
Transfer function of second order notch filter
add a comment |Â
up vote
2
down vote
No you are not missing anything. A moving average with a period of $T = 1/60$ seconds will indeed have a notch at 60 Hz, since the frequency response is a Sinc function with the first null at 1/T. (So it is both a low pass filter with an magnitude envelope that goes down as 1/f combined with a notches at integers of 1/T not including 0).
This is because a moving average has an impulse response that is a rectangular function of duration T, and the Fourier Transform of such a function is a Sinc (and the Fourier Transform of the Impulse Response is the Frequency Response). Digital Filters are similarly formed when the impulse response is a sampled rectangular function and thus their Fourier Transform will approach a Sinc function (what I like to refer as an "aliased" Sinc function similar to other aliasing in discrete time systems). If we position the sampling rate at integer multiples of 60 Hz, The null will be at 60 Hz and it's higher harmonics if the digital impulse response (formally called the unit sample response) is uniform samples for T duration, where T is 1/60 Hz (which is a moving average). Therefore the minimum sampling rate to do this digitally would be 120 Hz, otherwise 180 Hz, 240 Hz, etc.). Note that I said this would approach a Sinc function; notice the plots below of the actual frequency responses for each choice of sampling rate when we position the null at 60 Hz and do the moving average:
2 point moving average, sampling rate = 120 Hz
3 point moving average with sampling rate = 180 Hz
4 point moving average with sampling rate = 240 Hz
Also what you could alternatively consider which is even simpler is a "comb filter" structure which is simply the addition of the input with a delayed version of itself where the delay is equal to T/2.
This will have the frequency response according to:
$$H(omega) = 1 + e^jomega T/2$$
Since the Fourier Transform of a delay is given as
$$x(t) = delta(t-T) <==> x(omega) = e^-jomega T$$
With the magnitude plotted below:
This is equivalent to the digital filter with a delay of one sample when the sampling rate is 120 Hz, and a transfer function given as:
$$H(z) = 1+z^-1$$
with the frequency response when z is the unit circle as
$$H(e^jomega) = 1 + e^-jomega$$
with $omega$ going from 0 to $2pi$ in this case representing the normalized freq from 0 to the sampling rate.
If you are concerned about the "frequency droop" in your passband area for either of the above two solutions, you could consider using this very simple three tap FIR compensator described at this link for an elegant yet simple notch filter solution:
how to make CIC compensation filter
And here is a digital notch filter that I would typically implement when a very tight notch is required with a flat passband, to compare to the approaches above (and does not have the same limitations on sampling rates that can be used):
Transfer function of second order notch filter
add a comment |Â
up vote
2
down vote
up vote
2
down vote
No you are not missing anything. A moving average with a period of $T = 1/60$ seconds will indeed have a notch at 60 Hz, since the frequency response is a Sinc function with the first null at 1/T. (So it is both a low pass filter with an magnitude envelope that goes down as 1/f combined with a notches at integers of 1/T not including 0).
This is because a moving average has an impulse response that is a rectangular function of duration T, and the Fourier Transform of such a function is a Sinc (and the Fourier Transform of the Impulse Response is the Frequency Response). Digital Filters are similarly formed when the impulse response is a sampled rectangular function and thus their Fourier Transform will approach a Sinc function (what I like to refer as an "aliased" Sinc function similar to other aliasing in discrete time systems). If we position the sampling rate at integer multiples of 60 Hz, The null will be at 60 Hz and it's higher harmonics if the digital impulse response (formally called the unit sample response) is uniform samples for T duration, where T is 1/60 Hz (which is a moving average). Therefore the minimum sampling rate to do this digitally would be 120 Hz, otherwise 180 Hz, 240 Hz, etc.). Note that I said this would approach a Sinc function; notice the plots below of the actual frequency responses for each choice of sampling rate when we position the null at 60 Hz and do the moving average:
2 point moving average, sampling rate = 120 Hz
3 point moving average with sampling rate = 180 Hz
4 point moving average with sampling rate = 240 Hz
Also what you could alternatively consider which is even simpler is a "comb filter" structure which is simply the addition of the input with a delayed version of itself where the delay is equal to T/2.
This will have the frequency response according to:
$$H(omega) = 1 + e^jomega T/2$$
Since the Fourier Transform of a delay is given as
$$x(t) = delta(t-T) <==> x(omega) = e^-jomega T$$
With the magnitude plotted below:
This is equivalent to the digital filter with a delay of one sample when the sampling rate is 120 Hz, and a transfer function given as:
$$H(z) = 1+z^-1$$
with the frequency response when z is the unit circle as
$$H(e^jomega) = 1 + e^-jomega$$
with $omega$ going from 0 to $2pi$ in this case representing the normalized freq from 0 to the sampling rate.
If you are concerned about the "frequency droop" in your passband area for either of the above two solutions, you could consider using this very simple three tap FIR compensator described at this link for an elegant yet simple notch filter solution:
how to make CIC compensation filter
And here is a digital notch filter that I would typically implement when a very tight notch is required with a flat passband, to compare to the approaches above (and does not have the same limitations on sampling rates that can be used):
Transfer function of second order notch filter
No you are not missing anything. A moving average with a period of $T = 1/60$ seconds will indeed have a notch at 60 Hz, since the frequency response is a Sinc function with the first null at 1/T. (So it is both a low pass filter with an magnitude envelope that goes down as 1/f combined with a notches at integers of 1/T not including 0).
This is because a moving average has an impulse response that is a rectangular function of duration T, and the Fourier Transform of such a function is a Sinc (and the Fourier Transform of the Impulse Response is the Frequency Response). Digital Filters are similarly formed when the impulse response is a sampled rectangular function and thus their Fourier Transform will approach a Sinc function (what I like to refer as an "aliased" Sinc function similar to other aliasing in discrete time systems). If we position the sampling rate at integer multiples of 60 Hz, The null will be at 60 Hz and it's higher harmonics if the digital impulse response (formally called the unit sample response) is uniform samples for T duration, where T is 1/60 Hz (which is a moving average). Therefore the minimum sampling rate to do this digitally would be 120 Hz, otherwise 180 Hz, 240 Hz, etc.). Note that I said this would approach a Sinc function; notice the plots below of the actual frequency responses for each choice of sampling rate when we position the null at 60 Hz and do the moving average:
2 point moving average, sampling rate = 120 Hz
3 point moving average with sampling rate = 180 Hz
4 point moving average with sampling rate = 240 Hz
Also what you could alternatively consider which is even simpler is a "comb filter" structure which is simply the addition of the input with a delayed version of itself where the delay is equal to T/2.
This will have the frequency response according to:
$$H(omega) = 1 + e^jomega T/2$$
Since the Fourier Transform of a delay is given as
$$x(t) = delta(t-T) <==> x(omega) = e^-jomega T$$
With the magnitude plotted below:
This is equivalent to the digital filter with a delay of one sample when the sampling rate is 120 Hz, and a transfer function given as:
$$H(z) = 1+z^-1$$
with the frequency response when z is the unit circle as
$$H(e^jomega) = 1 + e^-jomega$$
with $omega$ going from 0 to $2pi$ in this case representing the normalized freq from 0 to the sampling rate.
If you are concerned about the "frequency droop" in your passband area for either of the above two solutions, you could consider using this very simple three tap FIR compensator described at this link for an elegant yet simple notch filter solution:
how to make CIC compensation filter
And here is a digital notch filter that I would typically implement when a very tight notch is required with a flat passband, to compare to the approaches above (and does not have the same limitations on sampling rates that can be used):
Transfer function of second order notch filter
edited 2 mins ago
answered 31 mins ago
Dan Boschen
8,5842933
8,5842933
add a comment |Â
add a comment |Â
up vote
1
down vote
A moving average is always a low pass filter, you are never going to get a notch at your desired frequency. You technically might be able to design it just right to have a notch at 60Hz, but you'll have notches at other frequencies. Also while the period of your signal may be 1 second, I suspect it will have higher frequency components.
Type this into matlab/octave with any number of N you'll find it is always a low pass.
N = 80
freqz(ones(1,N) * 1/N, 1)
A moving average is just a filter where all the coefficients are 1/N.
New contributor
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
add a comment |Â
up vote
1
down vote
A moving average is always a low pass filter, you are never going to get a notch at your desired frequency. You technically might be able to design it just right to have a notch at 60Hz, but you'll have notches at other frequencies. Also while the period of your signal may be 1 second, I suspect it will have higher frequency components.
Type this into matlab/octave with any number of N you'll find it is always a low pass.
N = 80
freqz(ones(1,N) * 1/N, 1)
A moving average is just a filter where all the coefficients are 1/N.
New contributor
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
A moving average is always a low pass filter, you are never going to get a notch at your desired frequency. You technically might be able to design it just right to have a notch at 60Hz, but you'll have notches at other frequencies. Also while the period of your signal may be 1 second, I suspect it will have higher frequency components.
Type this into matlab/octave with any number of N you'll find it is always a low pass.
N = 80
freqz(ones(1,N) * 1/N, 1)
A moving average is just a filter where all the coefficients are 1/N.
New contributor
A moving average is always a low pass filter, you are never going to get a notch at your desired frequency. You technically might be able to design it just right to have a notch at 60Hz, but you'll have notches at other frequencies. Also while the period of your signal may be 1 second, I suspect it will have higher frequency components.
Type this into matlab/octave with any number of N you'll find it is always a low pass.
N = 80
freqz(ones(1,N) * 1/N, 1)
A moving average is just a filter where all the coefficients are 1/N.
New contributor
edited 58 mins ago
New contributor
answered 1 hour ago
tteng
314
314
New contributor
New contributor
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
add a comment |Â
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
That's true in general. My question was specific considering the specific signal timings and moving average timings purposed..
â Learner
1 hour ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
If you think that is absolutely true and the signal characteristics will not go beyond that range then just low pass filter out to the highest frequency you expect.
â tteng
56 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdsp.stackexchange.com%2fquestions%2f52357%2fmoving-average-for-notch-filtering%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Moving averages are generally very poor low pass filters. They are useful when you don't have knowledge or a model for the noise or interferer. Here you know the interference is a narrow 60 Hz spike, so design a filter to do the job right: a notch filter is the correct thing to use.
â Andy Walls
43 mins ago
If you don't have a strict linear phase requirement and if the impulse response duration is not a matter then a simple second order IIR notch filter will pretty do your job.
â Fat32
33 mins ago