正在加载图片...
670 Chapter 15.Modeling of Data #include <math.h> #include "nrutil.h" #define BIG 1.0e30 extern int nn; extern float *xx,*yy,*sx,*sy,*ww,aa,offs; float chixy(float bang) Captive function of fitexy,returns the value of(x2-offs)for the slope b=tan(bang). Scaled data and offs are communicated via the global variables. int j; float ans,avex=0.0,avey=0.0,sumw=0.0,b; b=tan(bang); 83g for (i=1;i<=mn;i++){ 19881992 ww[j]=SQR(b*sx[j])+SQR(sy[j]); sumw +(ww[j](ww[j]1.0/BIG BIG 1.0/ww[j])); 11800 avex +ww[j]*xx[]; avey +ww[j]*yy[j]; 872 Cambridge n NUMERICAL RECIPES avex /sumw; avey /sumw; aa=avey-b*avex; for (ans -offs,j=1;j<=nn;j++) ans +ww[j]*SQR(yy[j]-aa-b*xx[j]); THE return ans; (North America 州bMe se to make one paper University Press. ART 是 Be aware that the literature on the seemingly straightforward subject of this section Programs is generally confusing and sometimes plain wrong.Deming's[1]early treatment is sound. but its reliance on Taylor expansions gives inaccurate error estimates.References[2-4]are reliable,more recent,general treatments with critiques of earlier work.York [5]and Reed [6] usefully discuss the simple case of a straight line as treated here,but the latter paper has 之 some errors.corrected in 7].All this commotion has attracted the Bayesians [8-10].who have still different points of view. OF SCIENTIFIC COMPUTING(ISBN 19891892 CITED REFERENCES AND FURTHER READING: Deming,W.E.1943,Statistical Adjustment of Data (New York:Wiley),reprinted 1964(New York: Dover).[1] FuurgPgoglrion Numerica 10621 Recipes 43108 Jefferys,W.H.1980,Astronomical Journal,vol.85,pp.177-181;see also vol.95,p.1299 (1988).[2] Jefferys,W.H.1981,Astronomical Journal,vol.86,pp.149-155;see also vol.95,p.1300 (outside (1988).[3] Lybanon,M.1984,American Journal of Physics,vol.52,pp.22-26.[4] North Software. York,D.1966,Canadian Journal of Physics,vol.44,pp.1079-1086.[5] Reed,B.C.1989,American Journal of Physics,vol.57,pp.642-646;see also vol.58,p.189, and vol..58,p.1209.[6 visit website machine Reed,B.C.1992,American Journal of Physics,vol.60,pp.59-62.[7] Zellner,A.1971,An Introduction to Bayesian Inference in Econometrics (New York:Wiley); reprinted 1987(Malabar,FL:R.E.Krieger Pub.Co.).[8] Gull,S.F.1989,in Maximum Entropy and Bayesian Methods,J.Skilling,ed.(Boston:Kluwer).[9] Jaynes,E.T.1991,in Maximum-Entropy and Bayesian Methods,Proc.10th Int.Workshop, W.T.Grandy,Jr.,and L.H.Schick,eds.(Boston:Kluwer).[10] Macdonald,J.R.,and Thompson,W.J.1992,American Journal of Physics,vol.60,pp.66-73.670 Chapter 15. Modeling 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). #include <math.h> #include "nrutil.h" #define BIG 1.0e30 extern int nn; extern float *xx,*yy,*sx,*sy,*ww,aa,offs; float chixy(float bang) Captive function of fitexy, returns the value of (χ2 − offs) for the slope b=tan(bang). Scaled data and offs are communicated via the global variables. { int j; float ans,avex=0.0,avey=0.0,sumw=0.0,b; b=tan(bang); for (j=1;j<=nn;j++) { ww[j] = SQR(b*sx[j])+SQR(sy[j]); sumw += (ww[j] = (ww[j] < 1.0/BIG ? BIG : 1.0/ww[j])); avex += ww[j]*xx[j]; avey += ww[j]*yy[j]; } avex /= sumw; avey /= sumw; aa=avey-b*avex; for (ans = -offs,j=1;j<=nn;j++) ans += ww[j]*SQR(yy[j]-aa-b*xx[j]); return ans; } Be aware that the literature on the seemingly straightforward subject of this section is generally confusing and sometimes plain wrong. Deming’s[1] early treatment is sound, but its reliance on Taylor expansions gives inaccurate error estimates. References[2-4] are reliable, more recent, general treatments with critiques of earlier work. York [5] and Reed [6] usefully discuss the simple case of a straight line as treated here, but the latter paper has some errors, corrected in [7]. All this commotion has attracted the Bayesians [8-10], who have still different points of view. CITED REFERENCES AND FURTHER READING: Deming, W.E. 1943, Statistical Adjustment of Data (New York: Wiley), reprinted 1964 (New York: Dover). [1] Jefferys, W.H. 1980, Astronomical Journal, vol. 85, pp. 177–181; see also vol. 95, p. 1299 (1988). [2] Jefferys, W.H. 1981, Astronomical Journal, vol. 86, pp. 149–155; see also vol. 95, p. 1300 (1988). [3] Lybanon, M. 1984, American Journal of Physics, vol. 52, pp. 22–26. [4] York, D. 1966, Canadian Journal of Physics, vol. 44, pp. 1079–1086. [5] Reed, B.C. 1989, American Journal of Physics, vol. 57, pp. 642–646; see also vol. 58, p. 189, and vol. 58, p. 1209. [6] Reed, B.C. 1992, American Journal of Physics, vol. 60, pp. 59–62. [7] Zellner, A. 1971, An Introduction to Bayesian Inference in Econometrics (New York: Wiley); reprinted 1987 (Malabar, FL: R. E. Krieger Pub. Co.). [8] Gull, S.F. 1989, in Maximum Entropy and Bayesian Methods, J. Skilling, ed. (Boston: Kluwer). [9] Jaynes, E.T. 1991, in Maximum-Entropy and Bayesian Methods, Proc. 10th Int. Workshop, W.T. Grandy, Jr., and L.H. Schick, eds. (Boston: Kluwer). [10] Macdonald, J.R., and Thompson, W.J. 1992, American Journal of Physics, vol. 60, pp. 66–73
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有