MATLAB hurst指数计算,Matlab 求Hurst 指数的计算程序

% The Hurst exponent

%--------------------------------------------------------------------------

% The first 20 lines of code are a small test driver.

% You can delete or comment out this part when you are done validating the

% function to your satisfaction.

%

% Bill Davidson, quellen@yahoo.com

% 13 Nov 2005

function []=hurst_exponent()

disp('testing Hurst calculation');

n=100;

data=rand(1,n);

plot(data);

hurst=estimate_hurst_exponent(data);

[s,err]=sprintf('Hurst exponent = %.2f',hurst);disp(s);

%--------------------------------------------------------------------------

% This function does dispersional analysis on a data series, then does a

% Matlab polyfit to a log-log plot to estimate the Hurst exponent of the

% series.

%

% This algorithm is far faster than a full-blown implementation of Hurst's

% algorithm.  I got the idea from a 2000 PhD dissertation by Hendrik J

% Blok, and I make no guarantees whatsoever about the rigor of this approach

% or the accuracy of results.  Use it at your own risk.

%

% Bill Davidson

% 21 Oct 2003

function [hurst] = estimate_hurst_exponent(data0)   % data set

data=data0;         % make a local copy

[M,npoints]=size(data0);

yvals=zeros(1,npoints);

xvals=zeros(1,npoints);

data2=zeros(1,npoints);

index=0;

binsize=1;

while npoints>4

y=std(data);

index=index+1;

xvals(index)=binsize;

yvals(index)=binsize*y;

npoints=fix(npoints/2);

binsize=binsize*2;

for ipoints=1:npoints % average adjacent points in pairs

data2(ipoints)=(data(2*ipoints)+data((2*ipoints)-1))*0.5;

end

data=data2(1:npoints);

end % while

xvals=xvals(1:index);

yvals=yvals(1:index);

logx=log(xvals);

logy=log(yvals);

p2=polyfit(logx,logy,1);

hurst=p2(1); % Hurst exponent is the slope of the linear fit of log-log plot

return;

发表于 @ 2008年09月14日 23:15:00|评论(loading...)|收藏

新一篇: 分形 Fractal | 旧一篇: 正在读risk and asset allocation - Attilio Meucci(Lehman brothers)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值