Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

hurst_spectrum.cpp

Go to the documentation of this file.
00001 
00002 #include <vector>
00003 
00004 #include "spectrum.h"
00005 #include "hurst_spectrum.h"
00006 #include "haar.h"
00007 #include "line_norm.h"
00008 #include "daub.h"
00009 
00010 using namespace std;
00011 
00047 void hurst_spectrum::spectrum_calc_( const double *v, 
00048                                      const size_t N,
00049                                      std::vector<double> &powerSpectrum )
00050 {
00051   //
00052   // Normalized wavelets
00053   //
00054   haar<double *> w;
00055   // line_norm<double *> w;
00056   // Daubechies<double *> w;
00057 
00058   double *data = new double[ N ];
00059   for (size_t i = 0; i < N; i++)
00060     data[i] = v[i];
00061 
00062   w.forwardTrans( data, N );
00063 
00064   spectrum::spectralCalc( data, N, powerSpectrum );
00065   delete [] data;
00066 } // spectrum_calc
00067 
00068 
00100 void hurst_spectrum::calc_hurst_est( const double *v, 
00101                                      const size_t N,
00102                                      hurstInfo &info )
00103 {
00104   vector<double> powerSpectrum;
00105 
00106   spectrum_calc_( v, N, powerSpectrum );
00107 
00108   const size_t numPts = powerSpectrum.size();
00109   size_t power = 8;
00110 
00111   (info.points()).clear();
00112   for (size_t octave = 3; octave < numPts; octave++) {
00113     double normPower = powerSpectrum[octave] / static_cast<double>(power);
00114     double logPower = log2( normPower );
00115     (info.points()).push_back( lregress::point( octave, logPower ) );
00116     power = power << 1;
00117   }
00118 
00119   // print_regression_points( info.points() );
00120   // printf("\n\n");
00121 
00122   lregress lr;
00123 
00124   lregress::lineInfo lineInfo;
00125   lr.lr( info.points(), lineInfo );
00126 
00127   double slope = lineInfo.slope();
00128   double intercept = lineInfo.intercept();
00129   double slopeError = lineInfo.slopeErr();
00130 
00131   info.slope( slope );
00132   info.slopeErr( slopeError );
00133   info.intercept( intercept );
00134 } // hurst_calc

Generated at Thu May 22 21:12:35 2003 for Hurst Exponent Calculation and Supporting Statistics by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001