正在加载图片...
642 Chapter 14. Statistical Description of Data en=n; en3n=en米en*en-en; aved=en3n/6.0-(sf+sg)/12.0; Expectation value of D. fac=(1.0-sf/en3n)*(1.0-sg/en3n) vard=((en-1.0)*en*en*SQR(en+1.0)/36.0)*fac; and variance of D give *zd=(*d-aved)/sqrt(vard); number of standard devia- *probd=erfcc(fabs(*zd)/1.4142136); tions and significance. *rs=(1.0-(6.0/en3n)*(*d+(sf+sg)/12.0))/sqrt(fac); Rank correlation coefficient, fac=(*rs+1.0)*(1.0-(*rs)); if (fac 0.0){ t=(*rs)*sqrt((en-2.0)/fac); and its t value, df=en-2.0; *probrs=betai(0.5*df,0.5,df/(df+t*t)); give its significance. else *probrs=0.0; free_vector(wksp2,1,n); free_vector(wksp1,1,n); g NUMERI ICAL void crank(unsigned long n,float w[],float *s) Given a sorted array w[1..n],replaces the elements by their rank,including midranking of ties, RECIPES I and returns as s the sum of f3-f,where f is the number of elements in each tie. unsigned long j=1,ji,jt; float t,rank; Press. *s=0.0; while (i<n){ 1f(w[j+1]I=w[j])[ Not a tie. [j]=j; ++ji else A tie: IENTIFIC for (jt=j+1;jt<=n&w[jt]==v[j];jt++); How far does it go? rank=0.5*(j+jt-1); This is the mean rank of the tie, for (ji=j;ji<=(jt-1);ji++)w[ji]=rank; so enter it into all the tied t=jt-ji entries, *g+=七*t*t-t; and update s. j=jt; 2 (ISBN if (i==n)w[n]=n; f the last element was not tied,this is its rank. Numerica 10.621 uctio Recipes 43108 Kendall's Tau (outside Kendall's r is even more nonparametric than Spearman's rs or D.Instead of Software. 首 using the numerical difference of ranks,it uses only the relative ordering of ranks higher in rank.lower in rank,or the same in rank.But in that case we don't even have to rank the data!Ranks will be higher,lower,or the same if and only if the values are larger,smaller,or equal,respectively.On balance,we prefer rs as being the more straightforward nonparametric test.but both statistics are in general use.In fact,T and rs are very strongly correlated and,in most applications,are effectively the same test. To define 7,we start with the N data points (xi,yi).Now consider all N(N-1)pairs of data points,where a data point cannot be paired with itself, and where the points in either order count as one pair.We call a pair concordant642 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). en=n; en3n=en*en*en-en; aved=en3n/6.0-(sf+sg)/12.0; Expectation value of D, fac=(1.0-sf/en3n)*(1.0-sg/en3n); vard=((en-1.0)*en*en*SQR(en+1.0)/36.0)*fac; and variance of D give *zd=(*d-aved)/sqrt(vard); number of standard devia- *probd=erfcc(fabs(*zd)/1.4142136); tions and significance. *rs=(1.0-(6.0/en3n)*(*d+(sf+sg)/12.0))/sqrt(fac); Rank correlation coefficient, fac=(*rs+1.0)*(1.0-(*rs)); if (fac > 0.0) { t=(*rs)*sqrt((en-2.0)/fac); and its t value, df=en-2.0; *probrs=betai(0.5*df,0.5,df/(df+t*t)); give its significance. } else *probrs=0.0; free_vector(wksp2,1,n); free_vector(wksp1,1,n); } void crank(unsigned long n, float w[], float *s) Given a sorted array w[1..n], replaces the elements by their rank, including midranking of ties, and returns as s the sum of f3 − f, w here f is the number of elements in each tie. { unsigned long j=1,ji,jt; float t,rank; *s=0.0; while (j < n) { if (w[j+1] != w[j]) { Not a tie. w[j]=j; ++j; } else { A tie: for (jt=j+1;jt<=n && w[jt]==w[j];jt++); Howfar does it go? rank=0.5*(j+jt-1); This is the mean rank of the tie, for (ji=j;ji<=(jt-1);ji++) w[ji]=rank; so enter it into all the tied t=jt-j; entries, *s += t*t*t-t; and update s. j=jt; } } if (j == n) w[n]=n; If the last element was not tied, this is its rank. } Kendall’s Tau Kendall’s τ is even more nonparametric than Spearman’s r s or D. Instead of using the numerical difference of ranks, it uses only the relative ordering of ranks: higher in rank, lower in rank, or the same in rank. But in that case we don’t even have to rank the data! Ranks will be higher, lower, or the same if and only if the values are larger, smaller, or equal, respectively. On balance, we prefer r s as being the more straightforward nonparametric test, but both statistics are in general use. In fact, τ and rs are very strongly correlated and, in most applications, are effectively the same test. To define τ, we start with the N data points (xi, yi). Now consider all 1 2N(N − 1) pairs of data points, where a data point cannot be paired with itself, and where the points in either order count as one pair. We call a pair concordant
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有