• 大小: 2KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2023-05-22
  • 语言: Matlab
  • 标签: 检验趋势  

资源简介

用matlab编的Manner-Kendall(M-K)程序非参数检验法常用于分析降水、径流、气温等要素时间序列的趋势变化,其优点在于样本不需要遵循某一特定的分布,而且很少受到异常值的的干扰,计算简便。

资源截图

代码片段和文件信息

% Time Series Trend Detection Tests
% [ z sl lcl ucl ] = trend( y dt )
% where z = Mann-Kendall Statistic
% sl = Sen‘s Slope Estimate
% lcl = Lower Confidence Limit of sl
% ucl = Upper Confidence Limit of sl
% y = Time Series of Data
% dt = Time Interval of Data
%y是待检测数据序列
% function [ z sl lcl ucl ] = mk( y )
%Data=xlsread(‘C:\Users\Win64\Desktop\分析研究方法\变异诊断\变异诊断程序\MK\shuju.xls‘‘B1:B50‘);
%y=Data(:9);
%y=y(y>0);
Data=xlsread(‘shuju.xls‘);
y=Data(:2);
n = length( y );
dt=1;

% calculate statistic
s = 0;
for k = 1:n-1
    for j = k+1:n
        s = s + sign( y(j) - y(k) );
    end;
end;

% variance ( assuming no tied groups )
v = ( n * ( n - 1 ) * ( 2 * n + 5 ) ) / 18;

% test statistic
if s == 0
z = 0;
elseif s > 0
z = ( s - 1 ) / sqrt( v );
else
z = ( s + 1 ) / sqrt( v );
end; 

% should calculate Normal value here
nor = 1.64;
% results
disp( [ ‘ n = ‘ num2str( 

评论

共有 条评论

相关资源