\HeaderA{bandwidth.nrd}{Bandwidth for density() via Normal Reference Distribution}{bandwidth.nrd}
\keyword{dplot}{bandwidth.nrd}
\begin{Description}\relax
A well-supported rule-of-thumb for choosing the bandwidth of a Gaussian
kernel density estimator.
\end{Description}
\begin{Usage}
\begin{verbatim}
bandwidth.nrd(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A data vector.

\end{ldescription}
\end{Arguments}
\begin{Value}
A bandwidth on a scale suitable for the \code{width} argument of
\code{density}.
\end{Value}
\begin{References}\relax
Venables, W. N. and Ripley, B. D. (2002)
\emph{Modern Applied Statistics with S.}
Springer, equation (5.5) on page 130.
\end{References}
\begin{Examples}
\begin{ExampleCode}
# The function is currently defined as
function(x)
{
        r <- quantile(x, c(0.25, 0.75))
        h <- (r[2] - r[1])/1.34
        4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5)
}
\end{ExampleCode}
\end{Examples}

