📄 exindex.m
字号:
function out=exindex(data,blocksize,opt)
%Estimates extremal index using blocks method
%
% USAGE: out=exindex(data,blocksize,opt)
%
% data: Data vector
%blocksize: Size of the blocks
% opt: Option for plotting.'t' or 'b' for plotting extremal index with respect to threshold
% or number of blocks in which the threshold is exceeded. If not entered no plot is
% generated.
%
% out: First column is K values (number of blocks in which a certain threshold is exceeded),
% second column is the corresponding threshold value,
% third column is the corresponding extremal index estimates.
warning off
if nargin>=2,
sorted=flipud(sort(data));
n=length(sorted);
r=blocksize;
k=round(n/r);
block_max=block(data,blocksize,'max');
block_max=flipud(sort(block_max(~isnan(block_max))));
un=unique(block_max);
un=un(1:end);
K=[];
for i=1:length(un),
ki=un(i)==block_max;
kif=find(ki);
kif=kif(1);
K(i)=kif-1;
end
N=[];
for i=1:length(un),
ni=un(i)==sorted;
nif=find(ni);
nif=nif(1);
N(i)=nif-1;
end
theta2=K./N;
theta=log(1-K/k)./(r*log(1-N/n));
out=[K',un,theta'];
out=out(1:end-1,:);
yrange=[min(theta) max(theta)];
index=K;
end
if nargin==3,
if strcmp(opt,'t'),
plot(un,theta)
eval(['xlabel(''Threshold''),' ' ylabel([texlabel(''theta'') ' ''' (''' ' num2str(k) ' ' ' ''' blocks of size ''' ' ' 'num2str(blocksize) ' ''')''' '])']);
elseif strcmp(opt,'b'),
plot(index,theta)
title('Threshold decreasing from left to right');
eval(['xlabel(''K''),' ' ylabel([texlabel(''theta'') ' ''' (''' ' num2str(k) ' ' ' ''' blocks of size ''' ' ' 'num2str(blocksize) ' ''')''' '])']);
else
error('3rd input should be one of ''t'' or ''b'' ')
end
end
warning on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -