Imagine the Universe!
Imagine Home  |   Teachers' Corner  |   Lesson Plans  |  

Creating Computer Code

In creating a computer code you must consider a few things:

This first is, you must be able to judge "high" and "low" values of chi. This is called the "reduced chi" value, or chi normalized by the number of degrees of freedom. The minimum value of chi then would be equal to 1. Thus, fits which result in a reduced chi near (but greater than) 1 would be acceptable. Fits with reduced chi values less than 1 are not real; fits with reduced chi much greater than 1 are poor fits and another equation is required.

The next consideration is the reduced chi equation.

rchisq = sum((y-yfit)**2/sigma**2/nfree

where y is the array of data points, sigma is the array of standard deviations for the data points, nfree is the number of degrees of freedom. And yfit is the fitted values of the data. Note that the number of degrees of freedom is equal to N-n-1, where N is the number of data points fit by (n+1) parameters.

For more information, you may want to consult the book Data Reduction and Error Analysis for the Physical Sciences, written by Philip R. Bevington and D. Keith Robinson.

Imagine the Universe is a service of the High Energy Astrophysics Science Archive Research Center (HEASARC), Dr. Alan Smale (Director), within the Astrophysics Science Division (ASD) at NASA's Goddard Space Flight Center.

The Imagine Team
Acting Project Leader: Dr. Barbara Mattson
All material on this site has been created and updated between 1997-2012.

DVD Table of Contents
Educator's Index