From: Clay on 11 Mar 2010 16:33 On Mar 11, 4:23 pm, spop...(a)speedymail.org (Steve Pope) wrote: > Clay <c...(a)claysturner.com> wrote: > >On Mar 11, 8:55 am, "Rachel2010" <HUGHMOLO...(a)GMAIL.COM> wrote: > >> I have a few periods of a signal converted to an ASCII *.txt file that I > >> want to apply Autocorrelation & Burg Method to seperately and then plot the > >> frequency response for each. Does anyone have optimized C code or Java for > >> doing so. Thank you. > >The book "Numerical Recipes in C" does have a routine for Maximum > >Entropy Method. The book (chapters at least) use to be on the web > >available for free. Try looking here:http://www.nr.com/ > > I think the MEM is unrelated to Rachel's problem, although > I could be mistaken. > > I assume the problem is to generate LPC coefficients by the > two different methods (autocorrelation followed by e.g. > Levinson-Durbin; or a lattice analyser using Burg arithmetic); > and to then compare the frequency response of the all-pole > filters generated by these two methods. > > ("Frequency response" possibly meaning the PSD of the > impulse response of these filters.) > > Steve It is highly related. With autocorrelation you generate a nice symmetric toeplitz matrix. Burg originated the recursive method for solving the matrix. This allows you to find a good estimate of the power spectrum of the data set.There are multiple names for this method: All Poles Model, Maximum Entrophy Method, and Autoregressive Model. Rachel mentioned she wanted to use autocorrelation and find the power spectrum. So this is the way. Clay
From: Rune Allnor on 11 Mar 2010 17:28 On 11 Mar, 22:33, Clay <c...(a)claysturner.com> wrote: > On Mar 11, 4:23 pm, spop...(a)speedymail.org (Steve Pope) wrote: > > > > > > > Clay <c...(a)claysturner.com> wrote: > > >On Mar 11, 8:55 am, "Rachel2010" <HUGHMOLO...(a)GMAIL.COM> wrote: > > >> I have a few periods of a signal converted to an ASCII *.txt file that I > > >> want to apply Autocorrelation & Burg Method to seperately and then plot the > > >> frequency response for each. Does anyone have optimized C code or Java for > > >> doing so. Thank you. > > >The book "Numerical Recipes in C" does have a routine for Maximum > > >Entropy Method. The book (chapters at least) use to be on the web > > >available for free. Try looking here:http://www.nr.com/ > > > I think the MEM is unrelated to Rachel's problem, although > > I could be mistaken. > > > I assume the problem is to generate LPC coefficients by the > > two different methods (autocorrelation followed by e.g. > > Levinson-Durbin; or a lattice analyser using Burg arithmetic); > > and to then compare the frequency response of the all-pole > > filters generated by these two methods. > > > ("Frequency response" possibly meaning the PSD of the > > impulse response of these filters.) > > > Steve > > It is highly related. With autocorrelation you generate a nice > symmetric toeplitz matrix. Burg originated the recursive method for > solving the matrix. This allows you to find a good estimate of the > power spectrum of the data set.There are multiple names for this > method: All Poles Model, Maximum Entrophy Method, and Autoregressive > Model. Rachel mentioned she wanted to use autocorrelation and find the > power spectrum. So this is the way. I never really understood the *practical* differences between the usual Yule-Walker equations and Burg's method. The way I saw this, the Yule-Walker equations pop out from a LMS analysis of the AR predictor, while Burg's method was based on maximizing the entropy of the residual. While the derivations and argument leading up to the results differed, the end results - the normal equations - were the same for both methods. And that's where I lost interest: As far as I were concerned, the same normal equations are solved the same way numerically, even if there were several possible derivations that lead up to the conclusion that the normal equations are useful. Where did I go wrong? Rune
From: Steve Pope on 11 Mar 2010 17:45 Clay <clay(a)claysturner.com> wrote: >On Mar 11, 4:23�pm, spop...(a)speedymail.org (Steve Pope) wrote: >> I think the MEM is unrelated to Rachel's problem, although >> I could be mistaken. >> I assume the problem is to generate LPC coefficients by the >> two different methods (autocorrelation followed by e.g. >> Levinson-Durbin; or a lattice analyser using Burg arithmetic); >> and to then compare the frequency response of the all-pole >> filters generated by these two methods. >> ("Frequency response" possibly meaning the PSD of the >> impulse response of these filters.) >It is highly related. With autocorrelation you generate a nice >symmetric toeplitz matrix. Burg originated the recursive method for >solving the matrix. This allows you to find a good estimate of the >power spectrum of the data set.There are multiple names for this >method: All Poles Model, Maximum Entrophy Method, and Autoregressive >Model. Rachel mentioned she wanted to use autocorrelation and find the >power spectrum. So this is the way. Okay, that's a different Burg method than the one I was thinking of above. IME "Burg method" most frequently refers to equation (1) in the following: http://www.eurasip.org/Proceedings/Eusipco/Eusipco2008/papers/1569102274.pdf There is no autocorrelation computed (since it is a lattice method), and I think Rachel wanted compare the autocorrelation and lattice methods. But I could be wrong, perhaps Rachel can clarify. Steve
From: Rachel2010 on 11 Mar 2010 17:48 >On 11 Mar, 22:33, Clay <c...(a)claysturner.com> wrote: >> On Mar 11, 4:23=A0pm, spop...(a)speedymail.org (Steve Pope) wrote: >> >> >> >> >> >> > Clay =A0<c...(a)claysturner.com> wrote: >> > >On Mar 11, 8:55 am, "Rachel2010" <HUGHMOLO...(a)GMAIL.COM> wrote: >> > >> I have a few periods of a signal converted to an ASCII *.txt file th= >at I >> > >> want to apply Autocorrelation & Burg Method to seperately and then p= >lot the >> > >> frequency response for each. Does anyone have optimized C code or Ja= >va for >> > >> doing so. Thank you. >> > >The book "Numerical Recipes in C" does have a routine for Maximum >> > >Entropy Method. The book (chapters at least) use to be on the web >> > >available for free. Try looking here:http://www.nr.com/ >> >> > I think the MEM is unrelated to Rachel's problem, although >> > I could be mistaken. >> >> > I assume the problem is to generate LPC coefficients by the >> > two different methods (autocorrelation followed by e.g. >> > Levinson-Durbin; or a lattice analyser using Burg arithmetic); >> > and to then compare the frequency response of the all-pole >> > filters generated by these two methods. >> >> > ("Frequency response" possibly meaning the PSD of the >> > impulse response of these filters.) >> >> > Steve >> >> It is highly related. With autocorrelation you generate a nice >> symmetric toeplitz matrix. Burg originated the recursive method for >> solving the matrix. This allows you to find a good estimate of the >> power spectrum of the data set.There are multiple names for this >> method: All Poles Model, Maximum Entrophy Method, and Autoregressive >> Model. Rachel mentioned she wanted to use autocorrelation and find the >> power spectrum. So this is the way. > >I never really understood the *practical* differences between >the usual Yule-Walker equations and Burg's method. The way >I saw this, the Yule-Walker equations pop out from a LMS >analysis of the AR predictor, while Burg's method was based >on maximizing the entropy of the residual. > >While the derivations and argument leading up to the results >differed, the end results - the normal equations - were the >same for both methods. And that's where I lost interest: >As far as I were concerned, the same normal equations are >solved the same way numerically, even if there were several >possible derivations that lead up to the conclusion that the >normal equations are useful. > >Where did I go wrong? > >Rune > Hi Guys, I should probobly clarify a little - i want to build all-pole models for a signal using the autocorrelation method and the Burg method and plot the frequency response for each of these models. I have a few periods of the signal already converted to an ASCII *.txt file. I've had a look and have come across the following code relating to Autocorrelation & Burg Method. I'm pretty new to this area and would appreciate any help in adapting the code to suit my requirements. If you could please take a look and give your feedback. //AUTOCORRELATION #include "stdafx.h" #include <sstream> #include <iostream> #include <fstream> #include <istream> #include <string> #include <vector> #define PI 3.14159265 typedef std::vector<float> float_vec_t; using namespace std; class LPCAnalysis{ public: float_vec_t LPCAnalysis::autoCorrelation(const float_vec_t &x); }; /* Calculate the (un-normalized) autocorrelation for a frame of a signal */ float_vec_t LPCAnalysis::autoCorrelation(const float_vec_t &x) { short order=x.size(); float_vec_t R(order); float sum; int i,j; for (i=0;i<order;i++) { sum=0; for (j=0;j<order-i;j++) { sum+=x[j]*x[j+i]; } R[i]=sum; } return R; } ------------------------------------------------------------------------- // Burg's algorithm int main( int argc, char *argv[] ) { // CREATE DATA TO APPROXIMATE vector<double> original( 128, 0.0 ); for ( size_t i = 0; i < original.size(); i++ ) { original[ i ] = cos( i * 0.01 ) + 0.75 *cos( i * 0.03 ) + 0.5 *cos( i * 0.05 ) + 0.25 *cos( i * 0.11 ); } // GET LINEAR PREDICTION COEFFICIENTS vector<double> coeffs( 4, 0.0 ); BurgAlgorithm( coeffs, original ); // LINEAR PREDICT DATA vector<double> predicted( original ); size_t m = coeffs.size(); for ( size_t i = m; i < predicted.size(); i++ ) { predicted[ i ] = 0.0; for ( size_t j = 0; j < m; j++ ) { predicted[ i ] -= coeffs[ j ] * original[ i - 1 - j ]; } } // CALCULATE AND DISPLAY ERROR double error = 0.0; for ( size_t i = m; i < predicted.size(); i++ ) { printf( "Index: %.2d / Original: %.6f / Predicted: %.6f\n", i, original[ i ], predicted[ i ] ); double delta = predicted[ i ] - original[ i ]; error += delta * delta; } printf( "Burg Approximation Error: %f\n", error ); return 0; } ------------------------------------------------------------------------- Thanks - Rachel.
From: Steve Pope on 11 Mar 2010 18:03 Rachel2010 <arcmax2005(a)yahoo.co.uk> wrote: >I should probobly clarify a little - i want to build all-pole models for a >signal using the autocorrelation method and the Burg method and plot the >frequency response for each of these models. Yes, you'll have to confirm whether "Burg Method" refers to the sense described by Clay, or the sense I assumed and which is described in the link within my last post. I notice a *lot* of Matlab/Mathworks material assumes the same definition as Clay is using. Whereas outside of that little universe it is more likely to refer to Burg's method of using a lattice analyzer... Steve
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: can the bessel filter be directly designed in digital domain? Next: FFTW and VB.NET |