%-----------------------------------------------------------------------
%;  Copyright (C) 1997
%;  Associated Universities, Inc. Washington DC, USA.
%;
%;  This program is free software; you can redistribute it and/or
%;  modify it under the terms of the GNU General Public License as
%;  published by the Free Software Foundation; either version 2 of
%;  the License, or (at your option) any later version.
%;
%;  This program is distributed in the hope that it will be useful,
%;  but WITHOUT ANY WARRANTY; without even the implied warranty of
%;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%;  GNU General Public License for more details.
%;
%;  You should have received a copy of the GNU General Public
%;  License along with this program; if not, write to the Free
%;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
%;  MA 02139, USA.
%;
%;  Correspondence concerning AIPS should be addressed as follows:
%;         Internet email: aipsmail@nrao.edu.
%;         Postal address: AIPS Project Office
%;                         National Radio Astronomy Observatory
%;                         520 Edgemont Road
%;                         Charlottesville, VA 22903-2475 USA
%-----------------------------------------------------------------------
\documentstyle [twoside]{article}
%
\newcommand{\AIPS}{{$\cal AIPS\/$}}
\newcommand{\AMark}{AIPSMark$^{(97)}$}
\newcommand{\AMarks}{AIPSMarks$^{(97)}$}
\newcommand{\AM}{A_m^{(97)}}
%
\newcommand{\whatmem}{\AIPS\ Memo \memnum}
\newcommand{\boxit}[3]{\vbox{\hrule height#1\hbox{\vrule width#1\kern#2%
\vbox{\kern#2{#3}\kern#2}\kern#2\vrule width#1}\hrule height#1}}
\newcommand{\memnum}{97}
\newcommand{\memtit}{Test of Errors of the Fitting Parameters at Gaussian Fitting task JMFIT.}
%
\setlength{\topmargin}{-8mm}
\setlength{\textwidth}{160mm}
\setlength{\textheight}{220mm}
\setlength{\oddsidemargin}{0mm}
%\setlength{\evensidemargin}{45mm}
\setlength{\evensidemargin}{0mm}
\setlength{\parindent}{3em}
\setlength{\unitlength}{10mm}
\input{epsf.sty}
\newcommand{\nl}{\newline}

\title{
%   \hphantom{Hello World} \\
   \vskip -35pt
%   \fbox{AIPS Memo \memnum} \\
   \fbox{{\large\whatmem}} \\
   \vskip 28pt
   \memtit \\}
%\title{Test of Errors of the Fitting Parameters at Gaussian Fitting task JMFIT}
\vspace{2 mm}

\author{ L.~Kogan
\vspace{2 mm}\\
\small National Radio Astronomy Observatory, Socorro, New Mexico,
USA\\}
%\date{September~ 5,~1993}
\vspace{2mm}

\begin{document}
\maketitle

\vspace{5mm}
\begin{abstract}
 Two-dimensional elliptical Gaussian fits are used in astronomy for accurate measurements of source parameters such as central position, peak flux density and angular size. The revised error analysis based on \cite{con} and \cite{kog} is implemented at the AIPS task JMFIT. A test of the errors of  six parameters of fitted Gaussian into an image provided by JMFIT has been carried out. The test demonstrates a good agreement with the error predicted by JMFIT.
\end{abstract}
\section{Correlation of the noise at the image pixels}
Many years ago the AIPS task IMFIT was written for fitting Gaussians at the image. The task found six parameters of the Gaussian together with predicted errors of each of them. For some reason (probably because of bad errors analysis) the people were not satisfied  by the task and the new one (very similar) JMFIT was written later. JMFIT used a different algorithm for evaluating the solution and mutual errors. Evaluation of the errors at the both tasks was done using the same formulae independent on the ratio of beam and Gaussian size that is incorrect. The new error analysis based on \cite{kog} uses different formulae depending on the ratio of beam and Gaussian size. Such a dependence takes a place because of difference in correlation of noises at the neighbor  pixels of image. Let's show that.
The visibility $V(\vec{B_i})$ measured at the given baseline $\vec{B_i}$ in the presence of noise $N(\vec{B_i})$ can be represented by the following equation:
\begin{equation}
V(\vec{B_i}) = V_{id}(\vec{B_i}) + N(\vec{B_i})
\label{eq:v(uv)}
\end{equation}
\begin{tabbing}
where~
\= $V_{id}(\vec{B_i})$ is the ideal visibility which would be measured \\
\> in the absence of noise.\\
\end{tabbing}
Having had the visibilities the image $Im(\vec{e})$ can be found as the Fourier transform:
\begin{equation}
Im(\vec{e}) = \frac{1}{I} \sum_{i} (V_{id}(\vec{B_i}) + N(\vec{B_i})) \cdot
\exp(j 2 \pi \, \vec{B_i}\cdot \vec{e})
\label{eq:im}
\end{equation}
\begin{tabbing}
where~
\= $\vec{e}$ is a vector at the picture plane of the source \\
\end{tabbing}
Correlation of the noise at the two different directions
 $\vec{e_1}, \vec{e_2}$
  at the picture plane is determined by the following equations:
\begin{eqnarray}
Cor(\vec{e_1}, \vec{e_2}) & = &
\overline{( Im(\vec{e_1}) - \overline{Im(\vec{e_1})} ) \cdot
    ( Im(\vec{e_2}) - \overline{Im(\vec{e_2})} ) } = \nonumber\\
& = &
= \frac{1}{I^2} \sum_i \sum_k \overline{N(\vec{B_i}) \, N(\vec{B_k})}
\exp(j 2 \pi \, \vec{B_i}\cdot \vec{e_1} ) \,
\exp(-j 2 \pi \, \vec{B_k}\cdot \vec{e_2})
\label{eq:cor1}
\end{eqnarray}
Noises at the different baselines are independent usually i.e.
$\overline{N(\vec{B_i}) \, N(\vec{B_k})} = 0 $ for different $i,k$.\\
Therefore the previous equation can be simplified:
\begin{equation}
Cor(\vec{e_1}, \vec{e_2})
= \frac{1}{I^2} \sum_i \overline{ N^2(\vec{B_i})}
\exp(j 2 \pi \, \vec{B_i}\cdot (\vec{e_1} - \vec{e_2} ))
\label{eq:cor2}
\end{equation}
If the noises variances are identical for all baselines (VLA, VLBA),
then:
\begin{equation}
Cor(\vec{e_1}, \vec{e_2})
= \frac{\overline{N^2}}{I} \frac {1}{I} \sum_i
\exp(j 2 \pi \, \vec{B_i}\cdot (\vec{e_1} - \vec{e_2} )) =
VARIM \cdot BEAM(\Delta \vec{e})
\label{eq:cor3}
\end{equation}
\begin{tabbing}
where~
\= $VARIM = \frac{\overline{N^2}}{I}$ is the noise variance at the image; \\
\> $BEAM(\Delta \vec{e}) = \frac {1}{I} \sum_i
\exp(j 2 \pi \, \vec{B_i}\cdot (\vec{e_1} - \vec{e_2} ))$ is the beam shape.\\
\end{tabbing}
{\em Thus, the correlation of the noise at the image pixels is completely determined by the beam shape }\\

We can  consider three types of sources:  very expanded source (the image is much bigger than the beam), the point source (image coincides with the beam), and intermediate case of partially resolved source.\\
\underline {A very expanded source}. The group of pixels inside of the beam area can be averaged and the averaged data are not correlated. So for very expanded source we can partially use the simplest theory of Gaussian parameters errors estimation supposing the noises uncorrelated. It is clear from this analysis, that errors should be proportional to {\bf sqrt} of ratio of area under the beam and under the image. \\
\underline {A point source}.~ All pixels noise at the image are deeply
correlated. This case was partially analyzed by Condon \cite{con}\\
\underline {Intermediate case}. This case is very difficult to analyze  especially when the beam is not circular. Interpolation between the two above cases was can be used.\\
The noise estimation has been installed at the AIPS task JMFIT recently.
Not all estimations are based on the strong theory. That is why the errors prediction given by JMFIT need in test. Beside of that the errors have not been ever tested experimentally and as a result some people do not trust them. The result of the test is given below.
\section{Test of the Errors}
\underline {A point source}.
The method of the test was offered by Dr. M. Goss. Cube of image with 64 frequency was used for the test. The given image included several point sources of different intensity. The task JMFIT was applied for 48 central frequencies to evaluate the rms of the measured parameters of the fitted Gaussian. This rms was compared with predicted rms given by JMFIT. Two sources with $\sim 10 \%$
and $\sim 25 \%$ of noise relatively the Gaussian peaks were selected. Combined image including all frequencies (so called CH0) was used to compare solutions.
The result of this test is given at tables 1 and 2. \\
\underline {An expanded source}. ~
To check the JMFIT error prediction for expanded sources UV data were simulated
using AIPS task UVMOD.  The source was selected 8 times (by area) larger than the beam.
Two value of implemented noise were used. The sequence of AIPS tasks: UVMOD
$\Rightarrow$ IMAGR $\Rightarrow$ JMFIT was repeated 16 times to have 16 independent measurement of the source. The result of the test is represented at the tables 3, 4. \\

{\em The comparison of predicted and measured errors of Gaussian fitting given at the tables 1-4 shows a good agreement for both point and expanded sources.
It proves that JMFIT's error analysis is plausible.}
\begin{thebibliography}{99}
  \bibitem{con} J.J. Condon, , PASP, 109, 1997, February
  \bibitem{kog} L. Kogan, AIPS memo~ 92, 1996
\end{thebibliography}
\newpage

\begin{table}
\caption{The Point source with ratio of rms to Gaussian peak  0.1}
\label{tab:1}
\begin{center}
\begin{tabular}{|c| c c c c|c c|} \hline
& \multicolumn{4}{c|}{Measured} &\multicolumn{2}{c|}{Predicted}\\ \cline{2-7}
       & Min& Max& Mean &rms & mean(ch0)& rms(JMFIT)\\
 \hline
PEAK  & 0.87    & 1.3   & 1.11  & 0.09 & 1.12  &0.07 $\rightarrow$ 0.1\\
INT   & 0.97    &1.87   & 1.3   & 0.18 & 1.2   &0.13 $\rightarrow$ 0.23\\
X     & 627.0   & 627.9 & 627.4 & 0.16 & 627.4 &0.1 $\rightarrow$ 0.2\\
Y     & 519.8   & 520.6 & 520.2 & 0.16 & 520.2 &0.1 $\rightarrow$ 0.2\\
MAJ   & 3.67    & 5.85  & 4.55  & 0.42 & 4.29  &0.25 $\rightarrow$ 0.5 \\
MIN   & 2.70    & 4.82  & 3.36  & 0.35 & 3.18  &0.2 $\rightarrow$ 0.43\\
BPA   & 13      &63     & 43    & 10   & 45    & 5 $\rightarrow$ 56\\
\hline
\end{tabular}
\end{center}
{\small
PEAK is the Gaussian peak value \\
INT is integral flux in the Gaussian \\
X,Y are the right ascension and declination position , in pixels \\
MAJ, MIN are the major and minor axes of the half cross ellipse, in pixels \\
BPA is position angle of the major axis, in degrees\\
}
\end{table}
\begin{table}
\caption{The Point source with ratio of rms to Gaussian peak  0.3}
\label{tab:2}
\begin{center}
\begin{tabular}{|c| c c c c|c c|} \hline
& \multicolumn{4}{c|}{Measured} &\multicolumn{2}{c|}{Predicted}\\ \cline{2-7}
       & Min& Max& Mean &rms & mean(ch0)& rms(JMFIT)\\
 \hline
PEAK  & 0.14    & 0.46   & 0.29  & 0.07 & 0.25  &0.07 $\rightarrow$ 0.09\\
INT   & 0.18    &1.9   & 0.7   & 0.37 & 0.36   &0.1 $\rightarrow$ 0.54\\
X     & 643.5   & 647.6 & 645.5 & 0.8 & 645.8 &0.35 $\rightarrow$ 2.6\\
Y     & 736.6   & 742.7 & 741.0 & 1.1 & 741.8 &0.35 $\rightarrow$ 2.1\\
MAJ   & 3.7    & 18  & 7.7  & 3.4 & 4.7  &1 $\rightarrow$ 8 \\
MIN   & 2    & 7.1  & 4.0  & 1.2 & 3.8  &0.5 $\rightarrow$ 2.5\\
BPA   & 7      &180     & 77    & 54   & 23    & 10 $\rightarrow$ 90\\
\hline
\end{tabular}
\end{center}
{\small
PEAK is the Gaussian peak value \\
INT is integral flux in the Gaussian \\
X,Y are the right ascension and declination position , in pixels \\
MAJ, MIN are the major and minor axes of the half cross ellipse, in pixels \\
BPA is position angle of the major axis, in degrees\\
}
\end{table}
\begin{table}
\caption{The expanded source (source/beam = 8) with ratio of rms to Gaussian peak  0.03}
\label{tab:3}
\begin{center}
\begin{tabular}{|c| c c c c|c c|} \hline
& \multicolumn{4}{c|}{Measured} &\multicolumn{2}{c|}{Predicted}\\ \cline{2-7}
       & Min& Max& Mean &rms &value& rms(JMFIT)\\
 \hline
PEAK  & 11.4    & 12.9   & 12  & 0.39 & 12.0  &0.28 $\rightarrow$ 0.45\\
INT   & 72.2    &84.3   & 78.8   & 3.3 & 81.5   &2.2 $\rightarrow$ 3\\
X     & 27.7   & 28.2 & 27.9 & 0.18 & 28 &0.16$\rightarrow$ 0.21\\
Y     & 34.1   & 34.9 & 34.5 & 0.23 & 34.3 &0.18 $\rightarrow$ 0.27\\
MAJ   & 18.1    & 20 & 19.1  & 0.52 & 20  &0.46 $\rightarrow$ 0.66 \\
MIN   & 13    & 14.3  & 13.6  & 0.37 & 13.3  &0.34 $\rightarrow$ 0.48\\
BPA   & 19      &34     & 27    & 4.8   & 25    & 2.9 $\rightarrow$ 5.5\\
\hline
\end{tabular}
\end{center}
{\small
PEAK is the Gaussian peak value \\
INT is integral flux in the Gaussian \\
X,Y are the right ascension and declination position , in pixels \\
MAJ, MIN are the major and minor axes of the half cross ellipse, in pixels \\
BPA is position angle of the major axis, in degrees\\
}
\end{table}
\begin{table}
\caption{The expanded source (source/beam = 8) with ratio of rms to Gaussian peak  0.2}
\label{tab:4}
\begin{center}
\begin{tabular}{|c| c c c c|c c|} \hline
& \multicolumn{4}{c|}{Measured} &\multicolumn{2}{c|}{Predicted}\\ \cline{2-7}
       & Min& Max& Mean &rms & value& rms(JMFIT)\\
 \hline
PEAK  & 8    & 18   & 12.1  & 2.3 & 12.0  &1 $\rightarrow$ 2.3\\
INT   & 51    &87   & 70   & 9.5 & 81.5   &6 $\rightarrow$ 18\\
X     & 23.2   & 29 & 27.4 & 1.4 & 28 &0.5$\rightarrow$ 2.9\\
Y     & 33.3   & 37 & 35 & 1.2 & 34.3 &0.5 $\rightarrow$ 2\\
MAJ   & 15    & 29 & 20.5  & 4.2 & 20  &1.3 $\rightarrow$ 7.7\\
MIN   & 9    & 16  & 11.6  & 2 & 13.3  &1 $\rightarrow$ 3.4\\
BPA   & 3      &154     & 56    & 49   & 25    & 3 $\rightarrow$ 90\\
\hline
\end{tabular}
\end{center}
{\small
PEAK is the Gaussian peak value \\
INT is integral flux in the Gaussian \\
X,Y are the right ascension and declination position , in pixels \\
MAJ, MIN are the major and minor axes of the half cross ellipse, in pixels \\
BPA is position angle of the major axis, in degrees\\
}
\end{table}
\end{document}









