1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
<html lang="en">
<head>
<title>Fitting Overview - GNU Scientific Library -- Reference Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Scientific Library -- Reference Manual">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Least_002dSquares-Fitting.html" title="Least-Squares Fitting">
<link rel="next" href="Linear-regression.html" title="Linear regression">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Free Software
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
and with the Back-Cover Text being (a) (see below). A copy of the
license is included in the section entitled ``GNU Free Documentation
License''.
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
GNU Manual, like GNU software.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Fitting-Overview"></a>
Next: <a rel="next" accesskey="n" href="Linear-regression.html">Linear regression</a>,
Up: <a rel="up" accesskey="u" href="Least_002dSquares-Fitting.html">Least-Squares Fitting</a>
<hr>
</div>
<h3 class="section">36.1 Overview</h3>
<p>Least-squares fits are found by minimizing \chi^2
(chi-squared), the weighted sum of squared residuals over n
experimental datapoints (x_i, y_i) for the model Y(c,x),
<pre class="example"> \chi^2 = \sum_i w_i (y_i - Y(c, x_i))^2
</pre>
<p class="noindent">The p parameters of the model are <!-- {$c = \{c_0, c_1, \dots\}$} -->
c = {c_0, c_1, <small class="dots">...</small>}. The
weight factors w_i are given by w_i = 1/\sigma_i^2,
where \sigma_i is the experimental error on the data-point
y_i. The errors are assumed to be
gaussian and uncorrelated.
For unweighted data the chi-squared sum is computed without any weight factors.
<p>The fitting routines return the best-fit parameters c and their
p \times p covariance matrix. The covariance matrix measures the
statistical errors on the best-fit parameters resulting from the
errors on the data, \sigma_i, and is defined
<a name="index-covariance-matrix_002c-linear-fits-2371"></a>as <!-- {$C_{ab} = \langle \delta c_a \delta c_b \rangle$} -->
C_{ab} = <\delta c_a \delta c_b> where <!-- {$\langle \, \rangle$} -->
< > denotes an average over the gaussian error distributions of the underlying datapoints.
<p>The covariance matrix is calculated by error propagation from the data
errors \sigma_i. The change in a fitted parameter \delta
c_a caused by a small change in the data \delta y_i is given
by
<pre class="example"> \delta c_a = \sum_i (dc_a/dy_i) \delta y_i
</pre>
<p class="noindent">allowing the covariance matrix to be written in terms of the errors on the data,
<pre class="example"> C_{ab} = \sum_{i,j} (dc_a/dy_i) (dc_b/dy_j) <\delta y_i \delta y_j>
</pre>
<p class="noindent">For uncorrelated data the fluctuations of the underlying datapoints satisfy
<!-- {$\langle \delta y_i \delta y_j \rangle = \sigma_i^2 \delta_{ij}$} -->
<\delta y_i \delta y_j> = \sigma_i^2 \delta_{ij}, giving a
corresponding parameter covariance matrix of
<pre class="example"> C_{ab} = \sum_i (1/w_i) (dc_a/dy_i) (dc_b/dy_i)
</pre>
<p class="noindent">When computing the covariance matrix for unweighted data, i.e. data with unknown errors,
the weight factors w_i in this sum are replaced by the single estimate w =
1/\sigma^2, where \sigma^2 is the computed variance of the
residuals about the best-fit model, \sigma^2 = \sum (y_i - Y(c,x_i))^2 / (n-p).
This is referred to as the <dfn>variance-covariance matrix</dfn>.
<a name="index-variance_002dcovariance-matrix_002c-linear-fits-2372"></a>
The standard deviations of the best-fit parameters are given by the
square root of the corresponding diagonal elements of
the covariance matrix, <!-- {$\sigma_{c_a} = \sqrt{C_{aa}}$} -->
\sigma_{c_a} = \sqrt{C_{aa}}.
The correlation coefficient of the fit parameters c_a and c_b
is given by <!-- {$\rho_{ab} = C_{ab} / \sqrt{C_{aa} C_{bb}}$} -->
\rho_{ab} = C_{ab} / \sqrt{C_{aa} C_{bb}}.
<hr>The GNU Scientific Library - a free numerical library licensed under the GNU GPL<br>Back to the <a href="/software/gsl/">GNU Scientific Library Homepage</a></body></html>
|