April 12, 2016 --- Class 25 --- Fitting Data, Chi-square Distribution
Activities:
Fitting Data
------------
We looked at what one should do to fit data to a model function.
If the data has a Gaussian distribution about its true value, then
we maximize the probability for the set of observations by
adjusting the parameters of the model to minimize \chi^2.
\chi^2= \Sum_{i=0}^N} (y_i- y_model(x_i)^2/ \sigma_i^2
Linear Model Function
---------------------
The case of a linear model was considered in great detail. We
obtained specific formulae for the slope and intercept parameters of
the fit. However, even with a formula for the slope and intercept,
there are two important questions:
1) How large is the error in the fitted parameters?
2) How good is the fit?
Using a standard propagation of errors approach, we found the error
on the slope. and intercept, and the covariance of those quantities.
Only one was worked out in detail.
Chi-squared Distribution
------------------------
In consideration of our second question we note that \chi^2 can be used to
determine the goodness of fit. Since \chi^2 should be the sum of
the squares of N normalized Gaussian variables, it has a known
distribution. If we find that our fit gives a small value of
\chi^2, that is good. If we get a large value, maybe our model is
not the correct description of the data. If the model has p
parameters that we adjust, the fit is said to have N-p degrees of
freedom. Soon we will look at a code to compute
the probabily that chisq is greater than the observed value.
This is called the confidence level of the fit. If your
confidence level gets below 5-10%, you begin to wonder if you
really have the right model for describing your data.
Analytic Approach to Chi-square Distribution
---------------------------------------------
We showed how the chi square distribution can be found by
integrating random variables in spherical coordinates. If we integrate
all the variables but the radial one, we find that the radial variable
is equivalent to the random variable chi-squared. In fact, we don't
even have to do the angular integral because it contributes to the
normalization and we can just normalize our probability distribution
function so that when we integrate it from 0 to infinity, we get one.
However, we did the radial integration, getting Euler's gamma
function and that allows us to calculate the "solid angle" of
an n-dimensional hypershere.
Here is a Mathematica expression for the chi-squared distribution:
chisq[x_, n_] := (x^((n - 2)/2)*Exp[-(x/2)])/(Gamma[n/2]*2^(n/2))