欢迎光临
我们一直在努力

matlab 的均值t检验用MATLAB做T检验ttest

t-检验:

t-检验,又称student‘s

t-test,可以用于比较两组数据是否来自同一分布(可以用于比较两组数据的区分度),假设了数据的正态性,并反应两组数据的方差在统计上是否有显著差异。

matlab中提供了两种相同形式的方法来解决这一假设检验问题,分别为ttest方法和ttest2方法,两者的参数、返回值类型均相同,不同之处在于ttest方法做的是?One-sample

and paired-sample t-test,而ttest2则是?Two-sample

t-test with pooled or unpooled variance

estimate,?performs an unpaired two-sample

t-test。但是这里至于paired和unpaired之间的区别我却还没搞清楚,只是在Student’s

t-test中看到了如下这样一段解释:

“Two-sample?t-tests for a difference

in mean involve independent samples, paired samples and overlapping

samples. Pairedt-tests are a form

of?blocking,

and have greater?power?than

unpaired tests when the paired units are similar with respect to

“noise factors” that are independent of membership in the two

groups being compared.In

a different context, paired?t-tests can

be used to reduce the effects ofconfounding

factors

因此粗略认为paired是考虑了噪声因素的。

在同样的两组数据上分别用ttest和ttest2方法得出的结果进行比较,发现ttest返回的参数p普遍更小,且置信区间ci也更小。

最常用用法:

[H,P,CI]=ttest2(x,y);(用法上ttest和ttest2相同,完整形式为[H,P,CI,

STATS]=ttest2(x,y, ALPHA);)

其中,x,y均为行向量(维度必须相同),各表示一组数据,ALPHA为可选参数,表示设置一个值作为t检验执行的显著性水平(performs

the test at the significance level

(100*ALPHA)%),在不设置ALPHA的情况下默认ALPHA为0.05,即计算x和y在5%的显著性水平下是否来自同一分布(假设是否被接受)

结果:H=0,则表明零假设在5%的置信度下不被拒绝(根据当设置x=y时候,返回的H=0推断而来),即x,y在统计上可看做来自同一分布的数据;H=1,表明零假设被拒绝,即x,y在统计上认为是来自不同分布的数据,即有区分度。

P为一个概率,matlab help中的解释是“ the p-value, i.e., the probability of

observing the given result, or one more extreme, by chance if the

null?hypothesis is true.?Small

values of P cast doubt on the validity of?the

null hypothesis.” 暂且认为表示判断值在真实分布中被观察到的概率(?不太懂)

CI为置信区间(confidence interval),表示“a 100*(1-ALPHA)% confidence

interval for the true difference of population

means”,即达到100*(1-ALPHA)%的置信度的数据区间(?)

应用:常与k-fold

crossValidation(交叉验证)联用可以用于两种算法效果的比较,例如A1,A2两算法得出的结果分别为x,y,且从均值上看mean(x)>mean(y),则对[h,p,ci]=ttest2(x,y);当h=1时,表明可以从统计上断定算法A1的结果大于(?)A2的结果(即两组数据均值的比较是有意义的),h=0则表示不能根据平均值来断定两组数据的大小关系(因为区分度小)

临时学的,没经过太多测试,不一定对,还请高手指教。

参考资料:

经验+自身理解

matlab 7.11.0(R2010b)的帮助文档

wikipedia

http://www.biosino.org/pages/newhtm/r/schtml/One_002d-and-two_002dsample-tests.html

本文中提到的pair应该如此理解:两个样本是有顺序的(比如两个病人24个整点的体温),两个同一序号(比如说6点)的体温为一个配对.而不配对的则不考虑这些,把24个体温放在一起看分布情况

04607638

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。