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

wave_hurst.cpp

Go to the documentation of this file.
00001 
00002 #include <assert.h>
00003 #include <stdio.h>
00004 
00005 #include "wave_hurst.h"
00006 #include "rescaled_range.h"
00007 #include "hurst_spectrum.h"
00008 
00030 void wave_hurst::test()
00031 {
00032   const size_t ReturnSize = 8192;
00033   const size_t DataSize = 8193;
00034 
00035   // These arrays have to be static to get around some Microsoft
00036   // wierdness with large stack allocated arrays.
00037   static double data[ DataSize ];
00038   static double returns[ ReturnSize ];
00039 
00040   //  for (size_t tableEntry = 0; tableEntry < tableSize_; tableEntry++) {
00041   //  const char *fileName = equityTable_[tableEntry].file();
00042     const char *fileName = "ibm_30year.csv";
00043     size_t n = DataSize;
00044     if (ts.getTS( fileName, data, n, yahooTS::Close )) {
00045       assert(n == DataSize );
00046 
00047       hurst_spectrum::hurstInfo waveInfo;
00048       hurst_spectrum wave;
00049 
00050       rescaled_range rs;
00051       rescaled_range::hurstInfo RSInfo;
00052 
00053       for (size_t blockSize = 1; blockSize <= 32; blockSize = (blockSize << 1)) {
00054         for (size_t i = 0; i < ReturnSize; i++)
00055           returns[i] = 0;
00056 
00057         size_t numReturns;
00058         numReturns = blockedLogReturn( data, returns, DataSize, blockSize );
00059 
00060         wave.calc_hurst_est( returns, numReturns, waveInfo );
00061         rs.calc_hurst_est( returns, numReturns, RSInfo );
00062 
00063         double H = fabs( (waveInfo.slope() - 1)/ 2 );
00064 
00075         printf("%2d %7.4f\n", blockSize, RSInfo.slope() );
00076       }
00077 
00085   } // for
00086 }

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