美文网首页
Matlab合成分析检验子函数

Matlab合成分析检验子函数

作者: 碧海蓝天_BLUE2016 | 来源:发表于2021-09-19 20:11 被阅读0次

该子函数根据Dr. Jianping Li的fortran函数改编
function [fh,fl,dh,dl,dhl,tn,ta,ta95] = hcfx(n,x,f,coefh,coefl)
% For a time series f(n), computing:
% (1) mean in the high index years of x(n)
% (2) mean in the low index years of x(n)
% (3) composite difference between the mean of f(n) in high
% index years of x(n) and its climatology average
% (4) composite difference between the mean of f(n) in low
% index years of x(n) and its climate average
% (5) composite difference between the means of f(n) in high
% and low index years of x(n)
% input: n,x(n),f(n),coefh,coefl
% n: the length of time series
% x: control variable (index),eg:降水指数
% f: given series,eg:风场
% coefh: control parameter for high index (i.e., high index years are
% those in which x(i) > coefh)
% coefl: control parameter for low index (i.e., low index years are
% those in which x(i) < coefl)
% output: fh,fl,dh,dl,dhl,tn(5)
% fh: the mean of f in high index years of x(n)
% fl: the mean of f in low index years of x(n)
% dh: composite difference between the mean of f in high index years of x(n)
% and its climate mean (i.e., high index years minus cliamte mean).
% dl: composite difference between the mean of f in low index years of x(n)
% and its climate mean (i.e., low index years minus cliamte mean).
% dhl: composite difference between the means of f in high and low index years
% of x(n) (i.e., high minus low index years)
% tn(i,j): tn only equals 2., -2., 1., -1. or 0. corresponding to significant difference or not.
% tn=2. indicates that the difference is positive and significant.
% tn=-2. indicates that the difference is negative and significant.
% tn=1. indicates that the difference is positive but not significant.
% tn=-1. indicates that the difference is negative but not significant.
% tn=0. indicates the difference is zero.
% tn(1,j)~tn(5,j) are corresponding to the 90%,95%,98%,99% and 99.9% confident levels.
% j=1: siginificant test for dh
% j=2: siginificant test for dl
% j=3: siginificant test for dhl
% Feburary 11, 2002 by Jianping Li.

nh=length(f(x>=coefh));
hn=f(x>=coefh);

nl=length(f(x<=coefl));
ln=f(x<=coefl);

fh=mean(f(x>=coefh));
fl=mean(f(x<=coefl));
avef=mean(f);
dh=fh-avef;
dl=fl-avef;
dhl=fh-fl;
[tn(:,1),ta(:,1),ta95(:,1)]=diff_t_test(nh,n,hn,f);
[tn(:,2),ta(:,2),ta95(:,2)]=diff_t_test(nl,n,ln,f);
[tn(:,3),ta(:,3),ta95(:,3)]=diff_t_test(nh,nl,hn,ln);
end
function [tn,ta,ta95] = diff_t_test(n,m,x,y)
% n,m两个样本的样本数,n特殊年,m所有年
% x,y两个样本的序列

nn=10000;
tn(1:5)=0;
ax=mean(x);
sx=std(x);
vx=sx.^2;
ay=mean(y);
sy=std(y);
vy=sy.^2;
sxy=(nvx+mvy)/(n+m-2);
sxy=sxy*(1./n+1./m);
sxy=sqrt(sxy);
% if sxy==0
dxy=ax-ay;
if(dxy>0)
sn=2;
tn(1:5)=1;
else
sn=-2;
tn(1:5)=-1;
end
ta=abs(dxy)/sxy;
nm=n+m-2;
[ft(:,1),ft(:,2),ft(:,3),ft(:,4),ft(:,5)]=t_table(nn);
ta95=ft(nm,2);
for i=1:5
if(ta>=ft(nm,i))
tn(i)=sn;
end
end
end

function [ft90,ft95,ft98,ft99,ft999]=t_table(n)
% t-distribution, i.e., student's distribution
% t table with two-tailed (right and left tails) probabilities
% P(|t|>=ta)=a
% where a (alpha) significance level and (1-a)*100% is confindence level.
% t90: t-distribution test at 90% confidence level.
% t95: t-distribution test at 95% confidence level.
% t98: t-distribution test at 98% confidence level.
% t99: t-distribution test at 99% confidence level.
% t999: t-distribution test at 99.9% confidence level.
% By Dr. Jianping Li, January 5, 2000.
% n=10000;
n90=[ 6314,2920,2353,2132,2015,1943,1895,1860,1833,1812,...,
1796,1782,1771,1761,1753,1746,1740,1734,1729,1725,...,
1721,1717,1714,1711,1708,1706,1703,1701,1699,1697];
n95=[12706,4303,3182,2776,2571,2447,2365,2306,2262,2228,...,
2201,2179,2160,2145,2131,2120,2110,2101,2093,2086,...,
2080,2074,2069,2064,2060,2056,2052,2048,2045,2042];
n98=[31821,6965,4541,3747,3365,3143,2998,2896,2821,2764,...,
2718,2681,2650,2624,2602,2583,2567,2552,2539,2528,...,
2518,2508,2500,2492,2485,2479,2473,2467,2462,2457];
n99=[63657,9925,5841,4604,4032,3707,3499,3355,3250,3169,...,
3106,3055,3012,2977,2947,2921,2898,2878,2861,2845,...,
2831,2819,2807,2797,2787,2779,2771,2763,2756,2750];
n999=[636619,31598,12941,8610,6859,5959,5405,5041,4781,...,
4587,4437,4318,4221,4140,4073,4015,3965,3922,3883,3850,...,
3819,3792,3767,3745,3725,3707,3690,3674,3659,3646];

ft90=n90/1000;
ft95=n95/1000;
ft98=n98/1000;
ft99=n99/1000;
ft999=n999/1000;

for i=31:40
fi=(i-30)/10;
ft90(i)=1.697-(1.697-1.684)fi;
ft95(i)=2.042-(2.042-2.021)
fi;
ft98(i)=2.457-(2.457-2.423)fi;
ft99(i)=2.750-(2.750-2.704)
fi;
ft999(i)=3.646-(3.646-3.551)fi;
end
for i=41:60
fi=(i-40)/20;
ft90(i)=1.684-(1.684-1.671)
fi;
ft95(i)=2.021-(2.021-2.000)fi;
ft98(i)=2.423-(2.423-2.390)
fi;
ft99(i)=2.704-(2.704-2.660)fi;
ft999(i)=3.551-(3.551-3.460)
fi;
end
for i=61:120
fi=(i-60)/60;
ft90(i)=1.671-(1.671-1.658)fi;
ft95(i)=2.000-(2.000-1.980)
fi;
ft98(i)=2.390-(2.390-2.358)fi;
ft99(i)=2.660-(2.660-2.617)
fi;
ft999(i)=3.460-(3.460-3.373)fi;
end
for i=121:n
fi=(i-120)/(n-120);
ft90(i)=1.658-(1.658-1.645)
fi;
ft95(i)=1.980-(1.980-1.960)fi;
ft98(i)=2.358-(2.358-2.326)
fi;
ft99(i)=2.617-(2.617-2.576)fi;
ft999(i)=3.373-(3.373-2.291)
fi;
end
end

相关文章

  • Matlab合成分析检验子函数

    该子函数根据Dr. Jianping Li的fortran函数改编function [fh,fl,dh,dl,dh...

  • 基于matlab 的长时间栅格数据的sen趋势分析

    基于matlab 的长时间栅格数据的sen趋势分析 sen趋势分析是进行趋势分析的方法之一,常配合MK检验来使用,...

  • matlab注意事项

    2018-05-06 matlab注意事项 1、在修改子函数后,要在run中也对其进行修改;

  • setState是同步还是异步?

    setState 只在合成事件和钩子函数中是“异步”的,在原生事件和 setTimeout 中都是同步的。 合成事...

  • scipy

    scipy处理matlab变量. help 显著性检验 link [out]:(0.393418620974391...

  • Matlab制作Video

    Matlab可以将图像序列合成为一段视频,其过程非常之简单:

  • {C#-05C} 单测.复合方法

    背景 合成多个子方法时传参多,责任不清时难单测 代码例 环境类 环境类单测 子函数 子函数单测 复合函数 复合函数单测

  • MK突变检验(Matlab)

    function [ UF,UB ] = MannKendall( x,y,p )% x表示时间如1982-201...

  • 基于Matlab的NDVI最大合成

    采用最大合成法将月数据ndvi合成年数据NDVI,本文以spot的月ndvi为例进行,利用matlab平台,代码如...

  • 参数检验和非参数检验简介

    在统计分析中分析中经常遇到某种检验方法为参数检验或非参数检验,例如T检验、Tukey检验、方差分析都属于参数检验,...

网友评论

      本文标题:Matlab合成分析检验子函数

      本文链接:https://www.haomeiwen.com/subject/yxajgltx.html