Index: trunk/doc/pslib/psLibADD.tex
===================================================================
--- trunk/doc/pslib/psLibADD.tex	(revision 4537)
+++ trunk/doc/pslib/psLibADD.tex	(revision 5059)
@@ -1,3 +1,3 @@
-%%% $Id: psLibADD.tex,v 1.85 2005-07-12 04:18:56 eugene Exp $
+%%% $Id: psLibADD.tex,v 1.86 2005-09-16 01:56:17 eugene Exp $
 \documentclass[panstarrs]{panstarrs}
 
@@ -324,18 +324,55 @@
 
 \begin{itemize}
-\item Perform the Robust Histogram Statistics algorithm above
-\item Smooth the resulting histogram with a Gaussian with $\sigma_s$ =
-  1 bin.
+\item Perform the Robust Histogram Statistics algorithm above,
+  yielding an estimated standard deviation, $\sigma$.
+
+\item Generate a new histogram for the data sample setting a bin size,
+  $d\sigma$, based on the estimated standard deviation and the number
+  of data points in the inner 50 percentile ($N_{\rm 50}$) as follows:
+
+\begin{itemize}
+\item let $dN = (\sigma / d\sigma) = 0.017 N_{50}$
+\item limit $dN$ to the range 1 to 5.
+\item set the bin size $d\sigma = \sigma / dN$
+\end{itemize}
+
+\item Smooth the resulting histogram with a Gaussian with $\sigma_x$ =
+  1 bin in this new histogram.
 \item Find the bin with the peak value in the range $\pm 2 \sigma$ of
   the robust histogram median.
-\item Fit a Gaussian to the bins in the range $\pm 2 \sigma$ of
-  the robust histogram median.
+
+\item Fit a Gaussian to the bins in the range $\pm 20 \sigma$ of the
+  robust histogram median. Limit the fit range to the data range, if
+  the latter is less then $\pm 20 \sigma$.  If the data range is small
+  compared to the estimated $\sigma$, fit at least 4 bins of the
+  hisgram centered on the robust histogram median.
+
 \item The robust mean $\mbox{mean}_r$ is derived directly from the
   fitted Gaussian mean.  
 \item The robust standard deviation, $\sigma_r$, is determined by
   subtracting the smoothing scale in quadrature: $\sigma_r^2 =
-  \sigma^2 - \sigma_s^2$
+  \sigma_{\rm fit}^2 - \sigma_s^2$
 \end{itemize}
 
+To explain the choice of the histogram bin size: a histogram of a
+Gaussian distribution with bin size $d\sigma$ will have approximately
+$(2.35 \sigma/d\sigma)$ bins covering the range LQ to UQ.  Thus, the
+average number of points per bin ($N_{\rm bin}$) in that interval will
+be $N_{50} / (2.35 \sigma/d\sigma)$.  The value of $d\sigma$ should be
+no larger than $\sigma$, regardless of the number of points, to avoid
+too much undersampling.  The value of $d\sigma$ should also be no
+smaller than $5\sigma$, again regardless of the number of points, to
+avoid excessive oversample.  Intermediate to those two values, the bin
+size is choosen to keep about 25 points per bin.  Thus, the bin size
+($d\sigma$) is set to about:
+\[
+d\sigma = 2.35 \sigma (N_{\rm bin}/N_{50}) = (25 \times 2.35) (\sigma/N_{50})
+\]
+With the limitation that $\sigma/d\sigma$ should be limited on one end
+to the value 1, and the other to the value 5.  The easiest way to set
+this limit is to define dN to be:
+\[
+dN = (\sigma / d\sigma) = (N_{50} / N_{\rm bin}) / 2.35 = 0.017 * N_{50}
+\]
 \subsubsection{Histograms}
 
