c14-6 (779581), страница 3
Текст из файла (страница 3)
Small values of prob indicate a significant correlation (tau positive) or anticorrelation(tau negative) between the two variables. Although tab is a float array, it will normallycontain integral values.{float erfcc(float x);long nn,mm,m2,m1,lj,li,l,kj,ki,k;float svar,s=0.0,points,pairs,en2=0.0,en1=0.0;nn=i*j;points=tab[i][j];for (k=0;k<=nn-2;k++) {ki=(k/j);kj=k-j*ki;points += tab[ki+1][kj+1];for (l=k+1;l<=nn-1;l++) {Total number of entries in contingency table.Loop over entries in table,decoding a row,and a column.Increment the total count of events.Loop over other member of the pair,Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).}}*tau=is/(sqrt((double) n1)*sqrt((double) n2));svar=(4.0*n+10.0)/(9.0*n*(n-1.0));*z=(*tau)/sqrt(svar);*prob=erfcc(fabs(*z)/1.4142136);14.7 Do Two-Dimensional Distributions Differ?645}}*tau=s/sqrt(en1*en2);svar=(4.0*points+10.0)/(9.0*points*(points-1.0));*z=(*tau)/sqrt(svar);*prob=erfcc(fabs(*z)/1.4142136);}CITED REFERENCES AND FURTHER READING:Lehmann, E.L. 1975, Nonparametrics: Statistical Methods Based on Ranks (San Francisco:Holden-Day).Downie, N.M., and Heath, R.W. 1965, Basic Statistical Methods, 2nd ed. (New York: Harper &Row), pp.
206–209.Norusis, M.J. 1982, SPSS Introductory Guide: Basic Statistics and Operations; and 1985, SPSSX Advanced Statistics Guide (New York: McGraw-Hill).14.7 Do Two-Dimensional Distributions Differ?We here discuss a useful generalization of the K–S test (§14.3) to two-dimensionaldistributions.
This generalization is due to Fasano and Franceschini [1], a variant on anearlier idea due to Peacock [2].In a two-dimensional distribution, each data point is characterized by an (x, y) pair ofvalues. An example near to our hearts is that each of the 19 neutrinos that were detectedfrom Supernova 1987A is characterized by a time ti and by an energy Ei (see [3]). Wemight wish to know whether these measured pairs (ti , Ei ), i = 1 . . . 19 are consistent with atheoretical model that predicts neutrino flux as a function of both time and energy — that is,a two-dimensional probability distribution in the (x, y) [here, (t, E)] plane. That would be aone-sample test.
Or, given two sets of neutrino detections, from two comparable detectors,we might want to know whether they are compatible with each other, a two-sample test.In the spirit of the tried-and-true, one-dimensional K–S test, we want to range overthe (x, y) plane in search of some kind of maximum cumulative difference between twotwo-dimensional distributions. Unfortunately, cumulative probability distribution is notwell-defined in more than one dimension! Peacock’s insight was that a good surrogate isthe integrated probability in each of four natural quadrants around a given point (xi , yi ),namely the total probabilities (or fraction of data) in (x > xi , y > yi ), (x < xi , y > yi ),(x < xi , y < yi ), (x > xi , y < yi ). The two-dimensional K–S statistic D is now takento be the maximum difference (ranging both over data points and over quadrants) of thecorresponding integrated probabilities.
When comparing two data sets, the value of D maydepend on which data set is ranged over. In that case, define an effective D as the averageSample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited.
To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).li=l/j;decoding its rowlj=l-j*li;and column.mm=(m1=li-ki)*(m2=lj-kj);pairs=tab[ki+1][kj+1]*tab[li+1][lj+1];if (mm) {Not a tie.en1 += pairs;en2 += pairs;s += (mm > 0 ? pairs : -pairs);Concordant, or discordant.} else {if (m1) en1 += pairs;if (m2) en2 += pairs;}.















