qplot.m

来自「极值理论中各种函数及图像的程序。matlab实现。」· M 代码 · 共 62 行

M
62
字号
function c=qplot(data,xi,ltrim,rtrim),
% Quantile Quantile plot for threshold data against the exponential distribution or the
% gpd with parameters xi (user input), mu=0 and beta=1.
%
% USAGE: c=qplot(data,xi,ltrim,rtrim)
%
%!!!data and xi should be supplied at least
%
%  data: data used.
%    xi: the xi value of a generalized Pareto distribution, if zero reference distribution
%        is exponential distribution.
% ltrim: Optional input. Value at which data are to be right-truncated.
% rtrim: Optional input. Value at which data are to be left-truncated.
%        If data will be truncated, one of ltrim and rtrim inputs should be defined and the
%        other should be left undefined and entered as '[ ]'.
data=surecol(data);
line=1;
      
      
if nargin < 2,
   error('Data and xi inputs should be supplied at least');
elseif nargin == 3,
 	error('One of ltrim and rtrim inputs should be defined, the other should be left undefined and entered as ''[ ]''');
elseif nargin == 4,
   if ~isempty(ltrim)&~isempty(rtrim),
      error('One of ltrim and rtrim inputs should be defined, the other should be left undefined and entered as ''[ ]'''); 
   end
   if ~isempty(ltrim) & isempty(rtrim)
   	data=data(data<=ltrim);   
	elseif ~isempty(rtrim) & isempty(ltrim),
	   data=data(data>=rtrim);
	else error('One of ltrim and rtrim inputs should be defined, the other should be left undefined and entered as ''[ ]''');    
end
else
end


if xi==0,
    ylab='Exponential Quantiles';
    y=expinv(ppoints(data),1);
end
if xi~=0,
    ylab=['GPD Quantiles; xi=' num2str(xi)];
    y=qgpd(ppoints(data),xi);
end
plot(sort(data),y,'.');
if line==1,
   hold on,
   x=sort(data);
   b=regress(y',[ones(size(x)) x]);
   plot([(1/b(2))*(max(y)-b(1));(1/b(2))*(min(y)-b(1))],[max(y);min(y)],'k');
   scx=range(x)/20;scy=range(y)/20;
   axis([min(x)-scx max(x)+scx min(y)-scy max(y)+scy]);
   hold off
   
end

ylabel(ylab);
xlabel('Ordered Data');
    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?