LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aggvar.m
1function H = aggvar(sequence,isplot)
2%
3% 'aggvar' estimate the hurst parameter of a given sequence with aggregate
4% variance 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% Outputs:
10% H: the estimated hurst coeffeient of the input sequence
11
12% Author: Chu Chen
13% Version 1.0, 03/10/2008
14% chen-chu@163.com
15%
16
17if nargin == 1
18 isplot = 0;
19end
20
21N = length(sequence);
22mlarge = floor(N/5);
23M = [floor(logspace(0,log10(mlarge),50))];
24M = unique(M(M>1));
25n = length(M);
26cut_min = ceil(n/10);
27cut_max = floor(6*n/10);
28
29V = zeros(1,n);
30for i = 1:n
31 m = M(i);
32 k = floor(N/m);
33 matrix_sequence = reshape(sequence(1:m*k),m,k);
34 V(i) = var(sum(matrix_sequence,1)/m);
35end
36
37x = log10(M);
38y = log10(V);
39y1 = -x+y(1)+x(1);
40X = x(cut_min:cut_max);
41Y = y(cut_min:cut_max);
42p1 = polyfit(X,Y,1);
43Yfit = polyval(p1,X);
44yfit = polyval(p1,x);
45beta = -(Yfit(end)-Yfit(1))/(X(end)-X(1));
46H = 1-beta/2;
47
48if isplot ~= 0
49 figure,hold on;
50 plot(x,y,'b*');
51 h = plot(x,y1);
52 plot(X,Yfit,'r-','LineWidth',2);
53 plot(x(1:cut_min),yfit(1:cut_min),'r:','LineWidth',2);
54 plot(x(cut_max:end),yfit(cut_max:end),'r:','LineWidth',2);
55 xlabel('log10(Aggreate Level)'), ylabel('log10(Viance)'), title('Time Viance Method');
56end