Matlab合成分析檢驗(yàn)子函數(shù)

該子函數(shù)根據(jù)Dr. Jianping Li的fortran函數(shù)改編
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:降水指數(shù)
% f: given series杉编,eg:風(fēng)場
% 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兩個(gè)樣本的樣本數(shù)德迹,n特殊年,m所有年
% x,y兩個(gè)樣本的序列

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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子倒庵,更是在濱河造成了極大的恐慌灯变,老刑警劉巖革娄,帶你破解...
    沈念sama閱讀 221,820評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異束析,居然都是意外死亡帘皿,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評論 3 399
  • 文/潘曉璐 我一進(jìn)店門畸陡,熙熙樓的掌柜王于貴愁眉苦臉地迎上來鹰溜,“玉大人,你說我怎么就攤上這事丁恭〔芏” “怎么了?”我有些...
    開封第一講書人閱讀 168,324評論 0 360
  • 文/不壞的土叔 我叫張陵牲览,是天一觀的道長墓陈。 經(jīng)常有香客問我,道長第献,這世上最難降的妖魔是什么贡必? 我笑而不...
    開封第一講書人閱讀 59,714評論 1 297
  • 正文 為了忘掉前任,我火速辦了婚禮庸毫,結(jié)果婚禮上仔拟,老公的妹妹穿的比我還像新娘。我一直安慰自己飒赃,他們只是感情好利花,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著载佳,像睡著了一般炒事。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上蔫慧,一...
    開封第一講書人閱讀 52,328評論 1 310
  • 那天挠乳,我揣著相機(jī)與錄音,去河邊找鬼姑躲。 笑死睡扬,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的肋联。 我是一名探鬼主播威蕉,決...
    沈念sama閱讀 40,897評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼橄仍!你這毒婦竟也來了韧涨?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,804評論 0 276
  • 序言:老撾萬榮一對情侶失蹤侮繁,失蹤者是張志新(化名)和其女友劉穎虑粥,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體宪哩,經(jīng)...
    沈念sama閱讀 46,345評論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡娩贷,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了锁孟。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片彬祖。...
    茶點(diǎn)故事閱讀 40,561評論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡茁瘦,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出储笑,到底是詐尸還是另有隱情甜熔,我是刑警寧澤,帶...
    沈念sama閱讀 36,238評論 5 350
  • 正文 年R本政府宣布突倍,位于F島的核電站腔稀,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏羽历。R本人自食惡果不足惜焊虏,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評論 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望秕磷。 院中可真熱鬧诵闭,春花似錦、人聲如沸跳夭。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽币叹。三九已至润歉,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間颈抚,已是汗流浹背踩衩。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留贩汉,地道東北人驱富。 一個(gè)月前我還...
    沈念sama閱讀 48,983評論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像匹舞,于是被迫代替她去往敵國和親褐鸥。 傳聞我的和親對象是個(gè)殘疾皇子偏陪,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評論 2 359

推薦閱讀更多精彩內(nèi)容

  • 八年級下冊 Unit1 What’s the matter? 【重點(diǎn)單詞】 matter [?m?t?] ...
    渾江257李明芳閱讀 858評論 0 0
  • 我的圖書館 留言交流 2000個(gè)最常用的英語單詞 2016-05-15酴羰駘璺 2000個(gè)最常用的英語單詞 (英語...
    Mr_Wang92閱讀 654評論 0 0
  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險(xiǎn)厭惡者锹安,不喜歡去冒險(xiǎn),但是人生放棄了冒險(xiǎn)详炬,也就放棄了無數(shù)的可能姊舵。 ...
    yichen大刀閱讀 6,057評論 0 4
  • 公元:2019年11月28日19時(shí)42分農(nóng)歷:二零一九年 十一月 初三日 戌時(shí)干支:己亥乙亥己巳甲戌當(dāng)月節(jié)氣:立冬...
    石放閱讀 6,888評論 0 2