正在加载图片...
618 Chapter 14.Statistical Description of Data avevar(datal,n1,&ave1,&var1); avevar(data2,n2,&ave2,&var2); *t=(ave1-ave2)/sqrt(var1/n1+var2/n2); df=SQR(var1/n1+var2/n2)/(SQR(var1/n1)/(n1-1)+SQR(var2/n2)/(n2-1)); *prob=betai(0.5*df,0.5,df/(df+SQR(*t))); Our final example of a Student's t test is the case of paired samples.Here we imagine that much of the variance in both samples is due to effects that are point-by-point identical in the two samples.For example,we might have two job candidates who have each been rated by the same ten members of a hiring committee. We want to know if the means of the ten scores differ significantly.We first try ttest above,and obtain a value of prob that is not especially significant (e.g., nted for >0.05).But perhaps the significance is being washed out by the tendency of some committee members always to give high scores,others always to give low scores, which increases the apparent variance and thus decreases the significance of any difference in the means.We thus try the paired-sample formulas, 1 Cov(A,B)N-1 >(Ai-A)(B:-TB) (14.2.5) 应@ 9 i1 Var(A)+Var(B)-2Cov(A:ZB) 1/2 SD= (14.2.6) N ts 工A-EB 9 (14.2.7) SD where N is the number in each sample (number of pairs).Notice that it is important SCIENTIFIC that a particular value of i label the corresponding points in each sample,that is, the ones that are paired.The significance of the t statistic in(14.2.7)is evaluated 6 for N-1 degrees of freedom. The routine is COMPUTING (ISBN 188810920 #include <math.h> void tptest(float datal,float data2[],unsigned long n,float *t, float *prob) Given the paired arrays data1[1..n]and data2[1..n],this routine returns Student's t for uurggoglrion Numerical Recipes 10-621 43108 paired data as t,and its significance as prob,small values of prob indicating a significant difference of means. (outside void avevar(float data,unsigned long n,float *ave,float *var); float betai(float a,float b,float x); Software. unsigned long j; float var1,var2,avel,ave2,sd,df,cov=0.0; avevar(datal,n,&ave1,&var1); avevar(data2,n,&ave2,&var2); for(j=1:j<=n;j++) cov +=(datal[i]-ave1)*(data2[i]-ave2); cov /df=n-1; sd=sqrt ((var1+var2-2.0*cov)/n); *t=(avel-ave2)/sd: *prob=betai(0.5*df,0.5,df/(df+(*t)*(*t)));618 Chapter 14. Statistical Description of Data Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). avevar(data1,n1,&ave1,&var1); avevar(data2,n2,&ave2,&var2); *t=(ave1-ave2)/sqrt(var1/n1+var2/n2); df=SQR(var1/n1+var2/n2)/(SQR(var1/n1)/(n1-1)+SQR(var2/n2)/(n2-1)); *prob=betai(0.5*df,0.5,df/(df+SQR(*t))); } Our final example of a Student’s t test is the case of paired samples. Here we imagine that much of the variance in both samples is due to effects that are point-by-point identical in the two samples. For example, we might have two job candidates who have each been rated by the same ten members of a hiring committee. We want to know if the means of the ten scores differ significantly. We first try ttest above, and obtain a value of prob that is not especially significant (e.g., > 0.05). But perhaps the significance is being washed out by the tendency of some committee members always to give high scores, others always to give low scores, which increases the apparent variance and thus decreases the significance of any difference in the means. We thus try the paired-sample formulas, Cov(xA, xB) ≡ 1 N − 1  N i=1 (xAi − xA)(xBi − xB) (14.2.5) sD =  Var(xA) + Var(xB) − 2Cov(xA, xB) N 1/2 (14.2.6) t = xA − xB sD (14.2.7) where N is the number in each sample (number of pairs). Notice that it is important that a particular value of i label the corresponding points in each sample, that is, the ones that are paired. The significance of the t statistic in (14.2.7) is evaluated for N − 1 degrees of freedom. The routine is #include <math.h> void tptest(float data1[], float data2[], unsigned long n, float *t, float *prob) Given the paired arrays data1[1..n] and data2[1..n], this routine returns Student’s t for paired data as t, and its significance as prob, small values of prob indicating a significant difference of means. { void avevar(float data[], unsigned long n, float *ave, float *var); float betai(float a, float b, float x); unsigned long j; float var1,var2,ave1,ave2,sd,df,cov=0.0; avevar(data1,n,&ave1,&var1); avevar(data2,n,&ave2,&var2); for (j=1;j<=n;j++) cov += (data1[j]-ave1)*(data2[j]-ave2); cov /= df=n-1; sd=sqrt((var1+var2-2.0*cov)/n); *t=(ave1-ave2)/sd; *prob=betai(0.5*df,0.5,df/(df+(*t)*(*t))); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有