next up previous contents
Next: Possible Extension Up: General Chi-Squared Fitting Previous: Description

Hints and Tips

Start by estimating an approximate solution. The circle centre is just the mean value of X and Y and the radius the mean distance of points from the centre. Have two functions that compute the first and second derivatives of RMS wrt. to X,Y,R. These functions compute numerical derivatives using get_rms Use these to estimate a better a solution and iterate. Again, a bit of theory may help:-

$\chi^2$ is a function of the parameters $c_\alpha$. At minimum:-

\begin{displaymath}{\partial \chi^2\over\partial c_\alpha}=0\end{displaymath}

In simple cases, the problem can be solved analytically. For example the fitting of a set of points (xi,yi) to the curve:-

\begin{displaymath}y=\sum_{\alpha}c_{\alpha} x^{\alpha}~~~~\alpha=0,1,2\cdots\eqno(1)\end{displaymath}

Then

\begin{displaymath}\chi^2=\sum_i {(y-y_i)}^2=\sum_i\left(\sum_{\alpha}c_{\alpha}
x_i^{\alpha}-y_i\right)^2\eqno(2)\end{displaymath}

and

\begin{displaymath}{\partial \chi^2\over\partial c_{\beta}}= 0 = 2\sum_i\left(\sum_{\alpha}
c_{\alpha}x_i^{\alpha}-y_i\right)x_i^{\beta}.\eqno(3)\end{displaymath}

So

\begin{displaymath}\sum_{\alpha}c_{\alpha}\sum_i x_i^{(\alpha+\beta)} = \sum_i y_i x_i^{\beta}
\eqno(4)\end{displaymath}

These are just a set of linear simultaneous equations in $c_\alpha$ which can be solved exactly.


Sometimes the problem is not so simple; either ${\partial \chi^2\over
\partial c_{\alpha}}$ can only be calculated numerically or it is not linear in $c_\alpha$. In such cases an iterative numerical approach can be used. The first step is to find some approximate solution and then to determine the first and second derivatives of $\chi^2$(numerically if necessary) at that point to find a better solution.

Suppose $c_\alpha$ is an approximate solution, we seek a better solution

\begin{displaymath}c_{\alpha}^{\prime}=c_{\alpha}+d_{\alpha}\end{displaymath}

and assume that it is not too far away, so that we can write

\begin{displaymath}\chi^2_{c_{\alpha}^{\prime}}=\chi^2_{c_{\alpha}}+
\left({\par...
...ta}}
\right)_{c_{\alpha}}\hskip-1em d_{\alpha}d_{\beta}\eqno(5)\end{displaymath}

If $c_{\alpha}^{\prime}$ is the minimum, then

\begin{displaymath}{\partial\chi^2_{c_{\alpha}^{\prime}}\over\partial d_{\alpha}}=0\end{displaymath}

so

\begin{displaymath}0=\left({\partial \chi^2\over\partial c_{\alpha}}\right)_{c_{...
...ha}\partial c_{\beta}}
\right)_{c_{\alpha}}\hskip-1em d_{\beta}\end{displaymath}

i.e.

\begin{displaymath}d_{\beta}=-\left({\partial^2\chi^2\over\partial c_{\alpha}\pa...
...ial\chi^2\over\partial c_{\alpha}}
\right)_{c_{\alpha}}\eqno(6)\end{displaymath}

Hence $d_{\beta}$ can be evaluated to find $c^{\prime}_{\alpha}$. The process can be repeated to further improve the solution until convergence is reached.


next up previous contents
Next: Possible Extension Up: General Chi-Squared Fitting Previous: Description
n west (APC)
2000-03-08