LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
absval.m
1function H = absval(sequence,isplot,moment)
2%
3% 'absval' estimate the hurst parameter of a given sequence with absolute
4% moment method.
5%
6% Inputs:
7% sequence: the input sequence for estimate
8% isplot: whether display the plot. without a plot if isplot equal to 0
9% moment: a positive interger which used to calculate absolute moment
10% Outputs:
11% H: the estimated hurst coeffeient of the input sequence
12
13% Author: Chu Chen
14% Version 1.0, 03/10/2008
15% chen-chu@163.com
16%
17
18if nargin == 1
19 moment = 1;
20 isplot = 0;
21end
22
23if nargin == 2
24 moment = 1;
25end
26
27sequence = sequence - mean(sequence);
28N = length(sequence);
29mlarge = floor(N/5);
30M = [floor(logspace(0,log10(mlarge),50))];
31M = unique(M(M>1));
32n = length(M);
33cut_min = ceil(n/10);
34cut_max = floor(6*n/10);
35
36A = zeros(1,n);
37for i = 1:n
38 m = M(i);
39 k = floor(N/m);
40 matrix_sequence = reshape(sequence(1:m*k),m,k);
41 A(i) = sum((abs(mean(matrix_sequence))).^moment)/k;
42end
43
44x = log10(M);
45y = log10(A);
46y1 = -x + y(1) + x(1);
47X = x(cut_min:cut_max);
48Y = y(cut_min:cut_max);
49
50p1 = polyfit(X,Y,1);
51Yfit = polyval(p1,X);
52yfit = polyval(p1,x);
53alpha = (Yfit(end)-Yfit(1))/(X(end)-X(1));
54H = 1+alpha/moment;
55
56if isplot ~= 0
57 figure,hold on;
58 plot(x,y,'b*');
59 plot(x,y1);
60 plot(X,Yfit,'r-','LineWidth',2);
61 plot(x(1:cut_min),yfit(1:cut_min),'r:','LineWidth',2);
62 plot(x(cut_max:end),yfit(cut_max:end),'r:','LineWidth',2);
63 xlabel('Log of Aggreate Level'), ylabel('Log of Absolute Moment'), title('Absolute Moment Method');
64end