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
00036
00037 static double data[ DataSize ];
00038 static double returns[ ReturnSize ];
00039
00040
00041
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 }
00086 }