%\input /pros/doc/scidoc/skeleton.tex
\def\version{\it Rev. 1.0 --- 3/31/86}
\def\chapter{\it Timing Analysis: Correlation analysis}
%\chapterhead{Science Specifications for the PROS}
%\chapterhead{Timing Analysis: Correlation Analysis}
\chapterhead{III.~Correlation Analysis}

\@{Overview}

\noindent
{\it Science Contact}:  R. Kelley (GSFC)

\noindent
{\it Function Purpose}: Calculate Autocorrelation Function (ACF) or
Cross Correlation Function (CCF) of a time series

\@{Input Data}

\item{}Plot/List files (see specification for `light curves').  One
file for ACF. Two files for CCF.

\@{Input Options}

\item{}Choose to perform either ACF or CCF

\@{Output Data}

\item{}None (?) - or should correlation functions be written to disk if requested?

\@{Output Display}

\item{}Linear graphics display of ACF or CCF.


\@{Full Description}

\**Autocorrelation Functions

{\list

The autocorrelation function, or ACF, is useful in the analysis of data that
are believed to result from a stochastic process.  Physically, the ACF is
a measure of the extent to which a time series is similar to itself when it is
shifted in time by a certain amount.  For example, in the shot-noise model,
which has been applied extensively in X-ray astronomy, the time series is
modeled as a sequence of flares, or shots, that occur randomly in time.  The
shape of the shots is often assumed to be exponential, and in this case it is
easy to show that the ACF will also have an exponential shape.  However, it
should be pointed out that the shape of an ACF is not a unique indicator of
the type of process involved.  Instead, one is usually left to the testing of
various kinds of models ({\it e.g.}, exponential {\it vs.} rectangular shots).

The simple autocorrelation function of the time series $x_i$ is defined by
the relation

}

$$A_j = \sum x_i x_{i+j}\qquad\qquad   i = 1 \ldots N-j$$

{\list

where $j$ is referred to as the \underbar{lag}.  
In practice it is more useful to define the ACF as

}

$$A_j = N^{-1} \sum (x_{i}-\mu)(x_{i+j} - \mu) \qquad\qquad  i=1
\ldots N-j,$$

{\list

where $\mu$ is the mean value of $x_i$.  Note that for $j = 0$,
$A_0$ is the
variance of $x_i$.

Weisskopf, Kahn and Sutherland (1975) have used a version
of the ACF that is weighted by according to the noise:

}

$$A_j = {{\sum_{i=1}^{N-j} (x_i - \mu) (x_{i+j}-\mu)/
 \sigma_i\sigma_{i+j}} \over 
{\sum_{i=1}^N 1/\sigma_i^2}}$$

{\list

The mean rate, $\mu$, must be calculated from the expression

}

$$\mu ={\sum^N_{i=1} x_i/\sigma^2_i \over \sum^N_{i=1} 1/\sigma_i^2}$$

{\list

This expression is recommended if, for some reason, the signal-to-noise ratio
of the data changes in time ({\it e.g.}, when scanning data are analyzed).  The
normalized ACF is defined by

}

$$r_j = A_j/A_0$$


\**Cross Correlation Functions

{\list

The cross correlation function (CCF) is a natural extension of the auto
correlation function.  It measures the extent to which two functions are
similar when one function is shifted relative to the other.  The CCF is thus
well-suited for searching for phase shifts between two signals.  For example,
one might imagine an X-ray flare where the onset of the flare occurs later at
low energies than at high energies.  To determine the time delay, one would
cross correlate the two energy channels and the peak in the CCF would occur at
the time difference between the two channels.

The CCF of the functions $x_i$ and $y_i$ is defined by

}

$$C_j = N^{-1} \sum (x_i-\mu_x)(y_{i+j}-\mu_y)
\qquad\qquad i = 1 \ldots N-j,$$

{\list

where $\mu_x$ and $\mu_y$ are the mean values of $x_i$ and $y_i$,
respectively.  Again, Weisskopf, Kahn and Sutherland (1975) give a more
general definition involving the statistical uncertainties (equation 8
of their paper).

In all of the expressions above, the sums are over the range 1 to $N-j$.  This
is referrred to as a \underbar{truncated} correlation.  In the figure below we show the
subscripts on the 10 point arrays $x_i$ and $x_{i+j}$ as an example of an ACF.
The ACF corresponds to multiplying the top line with one of the lines below it
and adding.  For the truncated sum, we would sum up only to the vertical line
(staircase) indicated.  One can define a 
\underbar{circular} correlation by ``wrapping" the
function $x_{i+j}$ around when $i+j > N$, and then summing $i = 1$ to $N$.  This is
useful in the case of periodic functions, such as the pulse profile of an X-ray
pulsar.

}

\vskip 12pt
\hbox to \hsize{\hfill
\vbox{
\offinterlineskip
\tabskip=0.em plus 1em minus 1em
\halign{
\vrule #  &
\strut \quad # \hfil\quad &
\vrule # \qquad &
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\hfil#\quad&
\vrule#\quad&
\hfil#\hfil&
\vrule #\cr
\noalign{\hrule}
height 6pt & \omit & height 6pt & &&&&&&&&&& height 6pt & & height 6pt\cr
&$x_i$&&1&2&3&4&5&6&7&8\phantom{0}&9\phantom{0}&10\phantom{1}&&& \cr
height 6pt & \omit & height 6pt & &&&&&&&&&& height 6pt & & height 6pt\cr
\noalign{\hrule}
height 6pt & \omit & height 6pt & &&&&&&&&&& height 6pt & & height 6pt\cr
&&&1&2&3&4&5&6&7&8\phantom{0}&9\phantom{0}&$\underline{10\mid}$&&j = 0 &\cr
&$x_{i+j}$&&2&3&4&5&6&7&8&9\phantom{0}&$\underline{10\mid}$&1\phantom{0}&&j = 1 &\cr
&&&3&4&5&6&7&8&9&$\underline{10\mid}$&1\phantom{0}&2\phantom{0}&&j = 2 &\cr
height 18pt & \omit & height 18pt & &&&&&&&&&& height 18pt & & height 18pt\cr
\noalign{\hrule}
}}\hskip 1.truein}

\vskip 16pt

{\list

For the case of a circular correlation, Fourier transforms can be employed
to reduce the computation time (note that the time to compute a correlation
function of $N$ points and $N$ lags scales a $N^2$).

It can be shown that the
Fourier transform of the cross correlation of the functions $x_i$
and $y_i$ is given by

}

$$C(f_k) = X^{\ast}(f_k)Y(f_k)$$


{\list 
 
where $X$ and $Y$ are the Fourier transforms of $x_i$ and $y_i$ respectively,
and $f_k$ is the $k^{th}$ Fourier frequency.  Hence, the circular correlation
function can be easily computed by performing three fast Fourier Transforms
(FFT's).  This would be particularly important if numbers of points are
involved.

Note that ACF is equal to the inverse Fourier transform of the power
density spectrum of the time series, so that an ACF can be computed with two
FFT's.

}

\@{References}

\refindent
Jenkins, G.M. and Watts, D.C. 1968, ``Spectral Analysis and It's Applications",
(San Francisco: Holden-Day).

\refindent
Sutherland, P.G., Weisskopf, M.C., and Kahn, S.M. 1978, {\it Ap.J.}, {\bf 219}, 1029.

\refindent
Weisskopf, M.C., Kahn, S.M., and Sutherland, P.G. 1975, {\it Ap.J. (Letters)},
{\bf 199} L147.


\vfill\eject
