1function H = peng(sequence,isplot)
3%
'peng' estimate the hurst parameter of a given sequence with residuals
7% sequence: the input sequence
for estimate
8% isplot: whether display the plot. without a plot
if isplot equal to 0
10% H: the estimated hurst coeffeient of the input sequence
13% Version 1.0, 03/10/2008
21% Calculate aggregate level.
23FBM = cumsum(sequence);
25msmall = max(10,log10(N)^2);
26M = floor(logspace(log10(msmall),log10(mlarge),50));
30cut_max = floor(7*n/10);
32% Calculate residuals under different aggregate level.
33Goble_residuals = zeros(1,n);
37 matrix_FBM = reshape(FBM(1:m*k),m,k);
39 Local_residual = zeros(1,k);
43 vv=[x
' ones(length(x),1)];
46 Local_residual(j) = norm_xx.^2/m;
49 Goble_residuals(i) = mean(Local_residual);
54y = log10(Goble_residuals);
55X = x(cut_min:cut_max);
56Y = y(cut_min:cut_max);
60H = 0.5*(Yfit(end)-Yfit(1))/(X(end)-X(1));
65 plot(X,Yfit,'r-
','LineWidth
',2);
66 plot(x(1:cut_min),yfit(1:cut_min),'r:
','LineWidth
',2);
67 plot(x(cut_max:end),yfit(cut_max:end),'r:
','LineWidth
',2);
68 xlabel('Log of Aggregate Level
'),ylabel('Log of Residual Vaiance
'),title('Peng Method
');