LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
boxper.m
1function H = boxper(sequence,isplot,boxnumber)
2%
3% 'boxper' estimate the hurst parameter of a given sequence with modified
4% periodogram 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 boxnumber = 50;
19 isplot = 0;
20end
21
22if nargin == 2
23 boxnumber = 50;
24end
25
26if boxnumber < 30 || boxnumber > 100
27 error('The input argument boxnumber must be a integer between [30,100]');
28end
29
30n = length(sequence);
31Xk = fft(sequence);
32P_origin = abs(Xk).^2/(2*pi*n);
33P = P_origin(1:floor(n/2)+1);
34
35cut_min = ceil(0.001*n/2);
36M = floor(logspace(log10(cut_min),log10(0.1*n-cut_min),boxnumber+1));
37M = unique(M);
38N = length(M)-1;
39
40x = zeros(1,N);
41y = zeros(1,N);
42for i = 1:N
43 m1 = M(i) + cut_min;
44 m2 = M(i+1) + cut_min;
45 x(i) = log10((pi * (m2 - m1))/(n));
46 y(i) = log10(sum(P(m1:m2))/(m2-m1+1));
47end
48
49X = x;
50Y = y;
51p1 = polyfit(X,Y,1);
52Yfit = polyval(p1,X);
53H = (1-(Yfit(end)-Yfit(1))/(X(end)-X(1)))/2;
54
55if isplot ~= 0
56 figure,clf,hold on;
57 plot(x,y,'b.');
58 plot(X,Yfit,'r-','LineWidth',2);
59 xlabel('Log10(Frequency)'),ylabel('Log10(Periodogram)'),title('Boxed Periodogram Method');
60end