\Header{jitter}{Add `Jitter' (Noise) to Numbers}
\keyword{dplot}{jitter}
\keyword{utilities}{jitter}
\begin{Usage}
\begin{verbatim}
jitter(x, factor=1, amount = NULL)
\end{verbatim}
\end{Usage}
\begin{Description}
\texttt{jitter(x,...)} returns a numeric of the same length as
\texttt{x}, but with an \texttt{amount} of noise added in order to break
ties. The result, say \texttt{r}, is \texttt{r <- x + runif(n, -a, a)}
where \texttt{n <- length(x)} and \texttt{a} is the \texttt{amount}
argument (if specified).\end{Description}
\begin{Details}
Let \texttt{z <- max(x) - min(x)} (assuming the usual case).
The amount \texttt{a} to be added is either provided as \emph{positive}
argument \texttt{amount} or otherwise computed from \texttt{z}, as
follows:

If \texttt{amount == 0}, we set \texttt{a <- factor * z/50} (same as S).

If \texttt{amount} is \texttt{NULL} (\emph{default}), we set
\texttt{a <- factor * d/5} where \emph{d} is the smallest
difference between adjacent unique (apart from fuzz) \texttt{x} values.\end{Details}
\begin{Author}
Werner Stahel and Martin Maechler, ETH Zurich\end{Author}
\begin{References}
Chambers, J.M., Cleveland, W.~S., Kleiner, B. and Tukey, P.A. (1983).
\emph{Graphical Methods for Data Analysis}, Wadsworth; figures 2.8,
4.22, 5.4.\end{References}
\begin{SeeAlso}
\texttt{\Link{rug}} which you may want to combine with \texttt{jitter}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
round(jitter(c(rep(1,3),  rep(1.2, 4), rep(3,3))), 3)
## These two `fail' with S-plus 3.x:
jitter(rep(0, 7))
jitter(rep(10000,5))
\end{ExampleCode}
\end{Examples}

