非参数检验及matlab实现_第1页
非参数检验及matlab实现_第2页
非参数检验及matlab实现_第3页
非参数检验及matlab实现_第4页
非参数检验及matlab实现_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、非参数检验及 matlab实现Kolmogorov-Smirnov test检验两个样本是否有相同分布KstestTest Statistics : max ( F (x) G (x)h,p,ksstat,cv = kstest(x,CDF,alpha,type)x:被测试的数据样本,以列向量输入(continuous distributiondefined by cumulative distribution function )CDF:被检验的样本 cumulative distribution function ,缺省值为 N(0,1)Alpha:显著性水平,缺省时为 0.05Type

2、:字符输入。'unequal'(缺省值)检验两者分布是否相同'larger'检验x的CDF大于给定的CDF'smaller'检验x的CDF小于给定的CDFh h=0不拒绝原假设,即两个分布相同h=1拒绝原假设,即两个分布不同p:拒绝原假设的最小显著性水平ksstat :假设为真时,满足 student分布cv: critical value/cutoff value , determining if ksstat is significant.Kstest2 :h,p,ks2stat = kstest2(x1,x2,alpha,type)详见ke

3、testLilliefors test检验两个样本是否有相同分布Test statistics : max(|f(x)-g(x)| )2-sided goodness-of-fit testlillietesth,p,kstat,critval = lillietest (x,alpha,distr,mctol)各参数参见kstest,特别的,mctol为使用蒙特卡洛方法计算p值Jarque-Bera test检验样本是否来自均值和方差未知的正态分布two-sided goodness-of-fit test假设:x为正态分布1 2、test statistic : jb =- s2 +(k

4、-3), where n is the sample size, s is61 4 ;the sample skewness, and k is the sample kurtosis.jbtesth,p,jbstat,critval = jbtest(x,alpha,mctol)各个参数意义详见lillietest 。Wilcoxon-Mann-Whitney Ranks Test检验两个样本是否来自于同一分布。以下 function f=Wilcoxon_Rank_Test(x,y,alpha) 直接是秩和检验方法, 另有function f=Pre_Wilcoxon(x,y,alpha)

5、是改进的秩和检验方法。区别 在于样本的处理方式。function f=Wilcoxon_Rank_Test(x,y,alpha);%x,y are vectors%x,y can be at different lengthZ=x;y;%z1 for ranking from small to large%z2 for placez1,z2=sort(Z, 'ascend' );for i=1:size(x,1)for j=i:size(z1,1)if z1(j)=x(i)X(i,1)=j;endendend%X is the rank of x in vectorm=size

6、(x,1);n=size(y,1);Ex=m*(m+n+1)/2;Varx=m*n*(m+n+1)/12;c=sqrt(Varx)*norminv(1-alpha/2);beta=sum(X,1);if abs(beta-Ex)>cdisp( 'Reject Null Hypothesis' );f=1;elsedisp('Fail to Reject Null Hypothesis' );f=0;end function f=Pre_Wilcoxon(x,y,alpha);%to find whether division is neededmemo=z

7、eros(size(x,1),size(y,1);for i=1:size(x,1)for j=1:size(y,1)if x(i,1)=y(j,1)memo(i,j)=1;endendend%memo contains the information of division;%memo is a symmetric matrix;if memo=zeros(size(memo)disp( 'No need for division' );disp('Go on Rank Test straightly' );disp('Reault as Follow

8、ing' ,'significant level' ,num2str(alpha);Wilcoxon_Rank_Test(x,y,alpha);elsedisp('Division is needed' );cx,cy=find(memo>0);if (cx(1,1)=1)&&(cy(1,1)=1)disp('group 1' );gamma=Wilcoxon_Rank_Test(x(1:cx(1),y(1:cy(1),alpha);if gamma=1;returnendfor k=1:size(cx,1)disp

9、('group ' ,num2str(k+1);gamma=Wilcoxon_Rank_Test(x(cx(k):cx(k+1),y(cy(k):cy(k+1),alpha );if gamma=1;breakendendelseif (cx(1)=1)&&(cy(1)=1)|(cx(1)=1)&&(cy(1)=1)gamma=0;disp( 'Reject Null Hypothesis' );end%(cx(1)=1)&&(cy(1)=1)for k=1:size(cx,1)disp('group &#

10、39; ,num2str(k+1);gamma=Wilcoxon_Rank_Test(x(cx(k):cx(k+1),y(cy(k):cy(k+1),alpha );if gamma=1;breakendendendend另外matlab中也有相关的自带的秩和检验函数:signrank/signtestp = signrank(x,y)为双侧检验,检验x, y是否来自中位数为0的整体;相似的,有 p = signtest(x,y)ranksump = ranksum(x,y)为双侧检验,检验x, y之间是否相互独立,要求x, y之间有相同的中位数Chi-square goodness-of-f

11、it test离散态的检验样本是否来自于已知分布。N2Test statistics : 片=£(Oi -Ei), where O i are the observed counts i aEiand E i are the expected counts. The statistic has an approximate chisquare distribution when the counts are sufficiently large.chi2gofh = chi2gof(x)H0 :x(列向量)来自正态分布(期望和方差来源于x) (defaultsignificance

12、level: 0.05 )h=0 fail to reject H 0h=1 rejectH 0或者h,p = chi2gof(x,'cdf',normcdf,mean(x),std(x)关于样本是否来自对称的分布function f=symmetric_test(x,alpha) %x is a vector%alpha is the significant level x1,x2=sort(x, 'ascend' );%x1 is x from min to max%x2 is the placen=size(x,1);x_ME=median(x,1); %median in column x_IQR=iqr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论