On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > filtered? > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > energy signals and power signals. These filters are studied > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > don't make sense with those sorts of data. > > > > > > > So, consider this sequence x_n given by > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > to filter out both components to find the residual e_n? > > > > > > Something may have gone missing in your expression above, > > > > > so I take the liberty to reformulate: > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > Assume for simplicity that we have N components and that > > > > > w = k/N*pi for some integer k. > > > > > > If we agree on this formulation, I put to you the following: > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > component at the frequency w. > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > at frequency w. > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > component at frequency w. > > > > > 4) In the event that all three terms contribute with > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > IIR filter will be able to separate the contributions > > > > > from each respective term. > > > > > > Rune > > > > > You answered four questions that I didn't ask. > > > > Because the phrasing of your post was and is ambiguous. > > > > > My question was simple: > > > > is it possible to filter out the periodic component in the above (non- > > > > stationary) time series with a FIR filter? > > > > The answer depends on exactly what you try to ask. > > > Gee, I'd think my question was rather clear. > > > > If you by > > > "the periodic component" means the term b*cos(w*n) -- and this > > > is how most people would understand the term > > > Me too. > > > > -- then the answer > > > is an unambiguous "No", the argument already being given. > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > Miracle: the periodic component is filtered out! > > No. Not "the" periodic component; "a" periodic component. > Try the same excercise with b = 0 and see what happens. > "Mystery": A periodic component which "does not exist in the > data" is filtered out!If it's not there you can't filter it out. Your replies are getting more mysterious as we go along.> > The insights as gained by the indicated excercise is what > distinguishes a competent data analyst from an arbitrary > numericist. The data analyst aims at learaning from the > data something he did not know before, and attempts to > relates the results of the analysis to whatever he is > intersted in learning. The numericist applies the algorithm > and accepts any result which does not result in a numerical > exception like divide by 0 or overflow.You seem to be in the mood for answering questions that nobody asked. Regards, Andor
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →
FIR Bandpass filtering (C code)
Started by ●March 31, 2007
Reply by ●April 3, 20072007-04-03
Reply by ●April 3, 20072007-04-03
On 3 Apr, 13:00, "Andor" <andor.bari...@gmail.com> wrote:> On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > > filtered? > > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > > energy signals and power signals. These filters are studied > > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > > don't make sense with those sorts of data. > > > > > > > > So, consider this sequence x_n given by > > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > > to filter out both components to find the residual e_n? > > > > > > > Something may have gone missing in your expression above, > > > > > > so I take the liberty to reformulate: > > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > > Assume for simplicity that we have N components and that > > > > > > w = k/N*pi for some integer k. > > > > > > > If we agree on this formulation, I put to you the following: > > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > > component at the frequency w. > > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > > at frequency w. > > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > > component at frequency w. > > > > > > 4) In the event that all three terms contribute with > > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > > IIR filter will be able to separate the contributions > > > > > > from each respective term. > > > > > > > Rune > > > > > > You answered four questions that I didn't ask. > > > > > Because the phrasing of your post was and is ambiguous. > > > > > > My question was simple: > > > > > is it possible to filter out the periodic component in the above (non- > > > > > stationary) time series with a FIR filter? > > > > > The answer depends on exactly what you try to ask. > > > > Gee, I'd think my question was rather clear. > > > > > If you by > > > > "the periodic component" means the term b*cos(w*n) -- and this > > > > is how most people would understand the term > > > > Me too. > > > > > -- then the answer > > > > is an unambiguous "No", the argument already being given. > > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > > Miracle: the periodic component is filtered out! > > > No. Not "the" periodic component; "a" periodic component. > > Try the same excercise with b = 0 and see what happens. > > "Mystery": A periodic component which "does not exist in the > > data" is filtered out! > > If it's not there you can't filter it out. Your replies are getting > more mysterious as we go along.C'mon, Andor. I might expect these sorts of objections from a 1st semester student, but from you? Ok, since it is you, I'll show you by spoon-feeding: %%%% Matlab code % First, set up the time vector. N = 128; nv = 0:N-1; % Discrete-time index vectr % Set up a ramp signal a = 1; % Slope of ramp x0 = a*nv; % Compute spectrum and plot magnitude X0 = fft(x0); plot(nv,abs(X0),'b.') % Next, the periodic component b = 10; % Amplitude wk = 6/N*2*pi; % Frequency % Add to the ramp signal x1 = x0 + b*cos(wk*nv); % Compute magnitude spectrum and plot in % same figure as the ramp X1 = fft(x1); hold on plot(nv,abs(X1),'.r') xlabel('Coefficient index, k') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% After you run this script, the k=6 coefficient in the ramp-only spectrum (plotted in blue) has a magnitude on the order of 440 or so, while the ramp + cosine coefficient, plotted in red, has a magnitude of 730. Based on filtering the ramp-only signal, you would not be able to tell that there is no cosine term in the signal model. Based on filtering the ramp + cosine signal, you would not be able to extract the cefficient b for the cosine term. Andor, you really disappoint me. I'll put it down to an early Easter leave... Rune
Reply by ●April 3, 20072007-04-03
On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 13:00, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > > > filtered? > > > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > > > energy signals and power signals. These filters are studied > > > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > > > don't make sense with those sorts of data. > > > > > > > > > So, consider this sequence x_n given by > > > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > > > to filter out both components to find the residual e_n? > > > > > > > > Something may have gone missing in your expression above, > > > > > > > so I take the liberty to reformulate: > > > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > > > Assume for simplicity that we have N components and that > > > > > > > w = k/N*pi for some integer k. > > > > > > > > If we agree on this formulation, I put to you the following: > > > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > > > component at the frequency w. > > > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > > > at frequency w. > > > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > > > component at frequency w. > > > > > > > 4) In the event that all three terms contribute with > > > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > > > IIR filter will be able to separate the contributions > > > > > > > from each respective term. > > > > > > > > Rune > > > > > > > You answered four questions that I didn't ask. > > > > > > Because the phrasing of your post was and is ambiguous. > > > > > > > My question was simple: > > > > > > is it possible to filter out the periodic component in the above (non- > > > > > > stationary) time series with a FIR filter? > > > > > > The answer depends on exactly what you try to ask. > > > > > Gee, I'd think my question was rather clear. > > > > > > If you by > > > > > "the periodic component" means the term b*cos(w*n) -- and this > > > > > is how most people would understand the term > > > > > Me too. > > > > > > -- then the answer > > > > > is an unambiguous "No", the argument already being given. > > > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > > > Miracle: the periodic component is filtered out! > > > > No. Not "the" periodic component; "a" periodic component. > > > Try the same excercise with b = 0 and see what happens. > > > "Mystery": A periodic component which "does not exist in the > > > data" is filtered out! > > > If it's not there you can't filter it out. Your replies are getting > > more mysterious as we go along. > > C'mon, Andor. I might expect these sorts of objections from a 1st > semester student, but from you?I have no idea what you are talking about.> Ok, since it is you, I'll show you by spoon-feeding:Mmmmh. [snip analysis of ramp and ramp + cos]> After you run this script, the k=6 coefficient in the > ramp-only spectrum (plotted in blue) has a magnitude > on the order of 440 or so, while the ramp + cosine > coefficient, plotted in red, has a magnitude of 730.That's very nice. It doesn't have the least to do with our discussion, though.> Based on filtering the ramp-only signal, you would > not be able to tell that there is no cosine term in > the signal model.After filtering, you can never tell if there was a cosine there or not BECAUSE IF IT WAS THERE, YOU JUST FILTERED IT OUT OF THE DATA FOR GOOD! Anycase, that was the whole point of the exercise: demonstrate that filtering works, regardless of the type of data (stationary, non- stationary, etc.).> Based on filtering the ramp + cosine > signal, you would not be able to extract the cefficient > b for the cosine term.I don't want to extract the coefficient b (sigh). I want to show that filtering works on any type of data.> > Andor, you really disappoint me. > I'll put it down to > an early Easter leave...Regards, Andor
Reply by ●April 3, 20072007-04-03
On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 13:00, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > > > filtered? > > > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > > > energy signals and power signals. These filters are studied > > > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > > > don't make sense with those sorts of data. > > > > > > > > > So, consider this sequence x_n given by > > > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > > > to filter out both components to find the residual e_n? > > > > > > > > Something may have gone missing in your expression above, > > > > > > > so I take the liberty to reformulate: > > > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > > > Assume for simplicity that we have N components and that > > > > > > > w = k/N*pi for some integer k. > > > > > > > > If we agree on this formulation, I put to you the following: > > > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > > > component at the frequency w. > > > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > > > at frequency w. > > > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > > > component at frequency w. > > > > > > > 4) In the event that all three terms contribute with > > > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > > > IIR filter will be able to separate the contributions > > > > > > > from each respective term. > > > > > > > > Rune > > > > > > > You answered four questions that I didn't ask. > > > > > > Because the phrasing of your post was and is ambiguous. > > > > > > > My question was simple: > > > > > > is it possible to filter out the periodic component in the above (non- > > > > > > stationary) time series with a FIR filter? > > > > > > The answer depends on exactly what you try to ask. > > > > > Gee, I'd think my question was rather clear. > > > > > > If you by > > > > > "the periodic component" means the term b*cos(w*n) -- and this > > > > > is how most people would understand the term > > > > > Me too. > > > > > > -- then the answer > > > > > is an unambiguous "No", the argument already being given. > > > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > > > Miracle: the periodic component is filtered out! > > > > No. Not "the" periodic component; "a" periodic component. > > > Try the same excercise with b = 0 and see what happens. > > > "Mystery": A periodic component which "does not exist in the > > > data" is filtered out! > > > If it's not there you can't filter it out. Your replies are getting > > more mysterious as we go along. > > C'mon, Andor. I might expect these sorts of objections from a 1st > semester student, but from you?I have no idea what you are talking about.> Ok, since it is you, I'll show you by spoon-feeding:Mmmmh. [snip analysis of ramp and ramp + cos]> After you run this script, the k=6 coefficient in the > ramp-only spectrum (plotted in blue) has a magnitude > on the order of 440 or so, while the ramp + cosine > coefficient, plotted in red, has a magnitude of 730.That's very nice. It doesn't have the least to do with our discussion, though.> Based on filtering the ramp-only signal, you would > not be able to tell that there is no cosine term in > the signal model.After filtering, you can never tell if there was a cosine there or not BECAUSE IF IT WAS THERE, YOU JUST FILTERED IT OUT OF THE DATA FOR GOOD! Anycase, that was the whole point of the exercise: demonstrate that filtering works, regardless of the type of data (stationary, non- stationary, etc.).> Based on filtering the ramp + cosine > signal, you would not be able to extract the cefficient > b for the cosine term.I don't want to extract the coefficient b (sigh). I want to show that filtering works on any type of data.> > Andor, you really disappoint me. > I'll put it down to > an early Easter leave...Regards, Andor
Reply by ●April 3, 20072007-04-03
On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 13:00, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > > > filtered? > > > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > > > energy signals and power signals. These filters are studied > > > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > > > don't make sense with those sorts of data. > > > > > > > > > So, consider this sequence x_n given by > > > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > > > to filter out both components to find the residual e_n? > > > > > > > > Something may have gone missing in your expression above, > > > > > > > so I take the liberty to reformulate: > > > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > > > Assume for simplicity that we have N components and that > > > > > > > w = k/N*pi for some integer k. > > > > > > > > If we agree on this formulation, I put to you the following: > > > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > > > component at the frequency w. > > > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > > > at frequency w. > > > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > > > component at frequency w. > > > > > > > 4) In the event that all three terms contribute with > > > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > > > IIR filter will be able to separate the contributions > > > > > > > from each respective term. > > > > > > > > Rune > > > > > > > You answered four questions that I didn't ask. > > > > > > Because the phrasing of your post was and is ambiguous. > > > > > > > My question was simple: > > > > > > is it possible to filter out the periodic component in the above (non- > > > > > > stationary) time series with a FIR filter? > > > > > > The answer depends on exactly what you try to ask. > > > > > Gee, I'd think my question was rather clear. > > > > > > If you by > > > > > "the periodic component" means the term b*cos(w*n) -- and this > > > > > is how most people would understand the term > > > > > Me too. > > > > > > -- then the answer > > > > > is an unambiguous "No", the argument already being given. > > > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > > > Miracle: the periodic component is filtered out! > > > > No. Not "the" periodic component; "a" periodic component. > > > Try the same excercise with b = 0 and see what happens. > > > "Mystery": A periodic component which "does not exist in the > > > data" is filtered out! > > > If it's not there you can't filter it out. Your replies are getting > > more mysterious as we go along. > > C'mon, Andor. I might expect these sorts of objections from a 1st > semester student, but from you?I have no idea what you are talking about.> Ok, since it is you, I'll show you by spoon-feeding:Mmmmh. [snip analysis of ramp and ramp + cos]> After you run this script, the k=6 coefficient in the > ramp-only spectrum (plotted in blue) has a magnitude > on the order of 440 or so, while the ramp + cosine > coefficient, plotted in red, has a magnitude of 730.That's very nice. It doesn't have the least to do with our discussion, though.> Based on filtering the ramp-only signal, you would > not be able to tell that there is no cosine term in > the signal model.After filtering, you can never tell if there was a cosine there or not BECAUSE IF IT WAS THERE, YOU JUST FILTERED IT OUT OF THE DATA FOR GOOD! Anycase, that was the whole point of the exercise: demonstrate that filtering works, regardless of the type of data (stationary, non- stationary, etc.).> Based on filtering the ramp + cosine > signal, you would not be able to extract the cefficient > b for the cosine term.I don't want to extract the coefficient b (sigh). I want to show that filtering works on any type of data.> > Andor, you really disappoint me. > I'll put it down to > an early Easter leave...Regards, Andor
Reply by ●April 3, 20072007-04-03
On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 13:00, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 3 Apr., 12:42, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > On 3 Apr, 10:01, "Andor" <andor.bari...@gmail.com> wrote: > > > > > On 3 Apr., 09:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > On 3 Apr, 09:25, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > On 2 Apr., 22:46, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > On 2 Apr, 22:10, "Andor" <andor.bari...@gmail.com> wrote: > > > > > > > > > On 2 Apr., 21:43, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > > > > > > > It's no limitation. Are you saying that only zero-mean data can be > > > > > > > > > > filtered? > > > > > > > > > > No. I'm saying that FIR and IIR filters only make sense for > > > > > > > > > energy signals and power signals. These filters are studied > > > > > > > > > in terms of the Fourier tranform, which requires the signals > > > > > > > > > to me integrable(?). The stock market data are not integrable > > > > > > > > > in the sense required by the FT, and hence FIR and IIR filters > > > > > > > > > don't make sense with those sorts of data. > > > > > > > > > So, consider this sequence x_n given by > > > > > > > > > x_n = alpha n + beta cos(w_0 n) + e_n, > > > > > > > > > where 0 < w_0 < pi is known and e_n is some noise. Are you saying I > > > > > > > > can't use an FIR to filter out the periodic componenent? Or yet > > > > > > > > another FIR to filter out the polynomial component? Or combine the two > > > > > > > > to filter out both components to find the residual e_n? > > > > > > > > Something may have gone missing in your expression above, > > > > > > > so I take the liberty to reformulate: > > > > > > > > x_n = a*n + b*cos(wn) + e_n a,b =/= 0 > > > > > > > > Assume for simplicity that we have N components and that > > > > > > > w = k/N*pi for some integer k. > > > > > > > > If we agree on this formulation, I put to you the following: > > > > > > > > 1) The ramp a*n may (or may not) have a non-zero Fourier > > > > > > > component at the frequency w. > > > > > > > 2) The cosine certainly has a non-zero Fourier component > > > > > > > at frequency w. > > > > > > > 3) The white noise does probably have a non-zero Fourier > > > > > > > component at frequency w. > > > > > > > 4) In the event that all three terms contribute with > > > > > > > non-zero Fourier components at frequency w, no FIR or > > > > > > > IIR filter will be able to separate the contributions > > > > > > > from each respective term. > > > > > > > > Rune > > > > > > > You answered four questions that I didn't ask. > > > > > > Because the phrasing of your post was and is ambiguous. > > > > > > > My question was simple: > > > > > > is it possible to filter out the periodic component in the above (non- > > > > > > stationary) time series with a FIR filter? > > > > > > The answer depends on exactly what you try to ask. > > > > > Gee, I'd think my question was rather clear. > > > > > > If you by > > > > > "the periodic component" means the term b*cos(w*n) -- and this > > > > > is how most people would understand the term > > > > > Me too. > > > > > > -- then the answer > > > > > is an unambiguous "No", the argument already being given. > > > > > Then apply the FIR [1 -2*cos(w_0) 1] to the data and see what happens. > > > > Miracle: the periodic component is filtered out! > > > > No. Not "the" periodic component; "a" periodic component. > > > Try the same excercise with b = 0 and see what happens. > > > "Mystery": A periodic component which "does not exist in the > > > data" is filtered out! > > > If it's not there you can't filter it out. Your replies are getting > > more mysterious as we go along. > > C'mon, Andor. I might expect these sorts of objections from a 1st > semester student, but from you?I have no idea what you are talking about.> Ok, since it is you, I'll show you by spoon-feeding:Mmmmh. [snip analysis of ramp and ramp + cos]> After you run this script, the k=6 coefficient in the > ramp-only spectrum (plotted in blue) has a magnitude > on the order of 440 or so, while the ramp + cosine > coefficient, plotted in red, has a magnitude of 730.That's very nice. It doesn't have the least to do with our discussion, though.> Based on filtering the ramp-only signal, you would > not be able to tell that there is no cosine term in > the signal model.After filtering, you can never tell if there was a cosine there or not BECAUSE IF IT WAS THERE, YOU JUST FILTERED IT OUT OF THE DATA FOR GOOD! Anycase, that was the whole point of the exercise: demonstrate that filtering works, regardless of the type of data (stationary, non- stationary, etc.).> Based on filtering the ramp + cosine > signal, you would not be able to extract the cefficient > b for the cosine term.I don't want to extract the coefficient b (sigh). I want to show that filtering works on any type of data.> > Andor, you really disappoint me. > I'll put it down to > an early Easter leave...Regards, Andor
Reply by ●April 3, 20072007-04-03
On 3 Apr, 14:17, "Andor" <andor.bari...@gmail.com> wrote:> On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote:> > > If it's not there you can't filter it out. Your replies are getting > > > more mysterious as we go along. > > > C'mon, Andor. I might expect these sorts of objections from a 1st > > semester student, but from you? > > I have no idea what you are talking about.I understand that now.> > Ok, since it is you, I'll show you by spoon-feeding: > > Mmmmh. > > [snip analysis of ramp and ramp + cos] > > > After you run this script, the k=6 coefficient in the > > ramp-only spectrum (plotted in blue) has a magnitude > > on the order of 440 or so, while the ramp + cosine > > coefficient, plotted in red, has a magnitude of 730. > > That's very nice. It doesn't have the least to do with our discussion, > though.It has everything to do with this discussion. The OP wanted to filter his data, which are modeled as a general trend like the ramp with a cosine superimposed, to extract the cosine. The excercise showed that you can't extract the cosine model term by this approach.> > Based on filtering the ramp-only signal, you would > > not be able to tell that there is no cosine term in > > the signal model. > > After filtering, you can never tell if there was a cosine there or not > BECAUSE IF IT WAS THERE, YOU JUST FILTERED IT OUT OF THE DATA FOR > GOOD!Where? I never filtered anything. I showed that a ramp function has a Fourier expasion, and that it is impossible to separate a cosine term from a Fourier coefficient from the ramp term.> Anycase, that was the whole point of the exercise: demonstrate > that filtering works, regardless of the type of data (stationary, non- > stationary, etc.).Again, this has to do with data analysis vs numerics. The FIR filter will produce a numerical result provided it is fed a sequence of data. rom a nmerical point of view, the filter "works." The only snag is that the result doesn't help answering the question; whether the data actually exhibit a periodic component on top of a generally increasing trend.> > Based on filtering the ramp + cosine > > signal, you would not be able to extract the cefficient > > b for the cosine term. > > I don't want to extract the coefficient b (sigh).I interpret the OP as to want this coefficient, and I certainly have discussed from the point of view that finding the coefficient b is the objective of the whole excercise.> I want to show that > filtering works on any type of data.Then why didn't you say so earlier? You would have wasted less time for both you and me.> > Andor, you really disappoint me. > > I'll put it down to > > an early Easter leave...Rune
Reply by ●April 3, 20072007-04-03
On Apr 3, 2:15 pm, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 14:17, "Andor" <andor.bari...@gmail.com> wrote: > > > On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > If it's not there you can't filter it out. Your replies are getting > > > > more mysterious as we go along. > > > > C'mon, Andor. I might expect these sorts of objections from a 1st > > > semester student, but from you? > > > I have no idea what you are talking about. > > I understand that now. > > > > Ok, since it is you, I'll show you by spoon-feeding: > > > Mmmmh. > > > [snip analysis of ramp and ramp + cos] > > > > After you run this script, the k=6 coefficient in the > > > ramp-only spectrum (plotted in blue) has a magnitude > > > on the order of 440 or so, while the ramp + cosine > > > coefficient, plotted in red, has a magnitude of 730. > > > That's very nice. It doesn't have the least to do with our discussion, > > though. > > It has everything to do with this discussion. The OP wanted to > filter his data, which are modeled as a general trend like > the ramp with a cosine superimposed, to extract the cosine. > > The excercise showed that you can't extract the cosine > model term by this approach.Only because the "spectrum" of the polynomial overlaps with that of the cosine. But this would be just as true if we replaced the polynomial with stationary wideband noise, or even a finite-energy deterministic signal like a sinc or a rect, or anything with a non- zero spectrum at the cosine frequency. Whether or not the overall signal is non-stationary seems to be irrelevant. -- Oli
Reply by ●April 3, 20072007-04-03
On 3 Apr., 15:15, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 14:17, "Andor" <andor.bari...@gmail.com> wrote: > > > On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > If it's not there you can't filter it out. Your replies are getting > > > > more mysterious as we go along. > > > > C'mon, Andor. I might expect these sorts of objections from a 1st > > > semester student, but from you? > > > I have no idea what you are talking about. > > I understand that now. > > > > Ok, since it is you, I'll show you by spoon-feeding: > > > Mmmmh. > > > [snip analysis of ramp and ramp + cos] > > > > After you run this script, the k=6 coefficient in the > > > ramp-only spectrum (plotted in blue) has a magnitude > > > on the order of 440 or so, while the ramp + cosine > > > coefficient, plotted in red, has a magnitude of 730. > > > That's very nice. It doesn't have the least to do with our discussion, > > though. > > It has everything to do with this discussion. The OP wanted to > filter his data, which are modeled as a general trend like > the ramp with a cosine superimposed, to extract the cosine.That's also possible.> The excercise showed that you can't extract the cosine > model term by this approach.Of course you can. To filter out a n-th degree polynomial trend, just use a filter with an (n+1)-th order zero at zero. For example, the linear trend can be removed using a second order difference filter. However, we (or rather you) are again digreessing. To cut this short, all I did was to dispute your claim (made in the first post that I replied to) "The stock market data don't comply with the assumtions about data the FIR filter techniques is based on." which is quite clearly wrong, no matter how many FFTs you throw around you. Stock market or not, sequences of numbers can always be filtered with FIRs, and the results are always the same. Regards, Andor
Reply by ●April 3, 20072007-04-03
On 3 Apr., 15:15, "Rune Allnor" <all...@tele.ntnu.no> wrote:> On 3 Apr, 14:17, "Andor" <andor.bari...@gmail.com> wrote: > > > On 3 Apr., 13:48, "Rune Allnor" <all...@tele.ntnu.no> wrote: > > > > If it's not there you can't filter it out. Your replies are getting > > > > more mysterious as we go along. > > > > C'mon, Andor. I might expect these sorts of objections from a 1st > > > semester student, but from you? > > > I have no idea what you are talking about. > > I understand that now. > > > > Ok, since it is you, I'll show you by spoon-feeding: > > > Mmmmh. > > > [snip analysis of ramp and ramp + cos] > > > > After you run this script, the k=6 coefficient in the > > > ramp-only spectrum (plotted in blue) has a magnitude > > > on the order of 440 or so, while the ramp + cosine > > > coefficient, plotted in red, has a magnitude of 730. > > > That's very nice. It doesn't have the least to do with our discussion, > > though. > > It has everything to do with this discussion. The OP wanted to > filter his data, which are modeled as a general trend like > the ramp with a cosine superimposed, to extract the cosine.That's also possible.> The excercise showed that you can't extract the cosine > model term by this approach.Of course you can. To filter out a n-th degree polynomial trend, just use a filter with an (n+1)-th order zero at zero. For example, the linear trend can be removed using a second order difference filter. However, we (or rather you) are again digreessing. To cut this short, all I did was to dispute your claim (made in the first post that I replied to) "The stock market data don't comply with the assumtions about data the FIR filter techniques is based on." which is quite clearly wrong, no matter how many FFTs you throw around you. Stock market or not, sequences of numbers can always be filtered with FIRs, and the results are always the same. Regards, Andor







