\HeaderA{PTBmu.gen}{generator functions for multiple rounds of noise}{PTBmu.gen}
\aliasA{PTBmn.gen}{PTBmu.gen}{PTBmn.gen}
\keyword{misc}{PTBmu.gen}
\keyword{optimize}{PTBmu.gen}
\keyword{distribution}{PTBmu.gen}
\begin{Description}\relax
These functions generate a function that will apply multiple rounds of noise.
These are helper functions for \code{\LinkA{perturb}{perturb}}, and generate functions of the form of
\code{\LinkA{PTBn}{PTBn}}.
They are used to select the type and magnitude of
noise applied to each vector in the data frame,
when running the perturbation sensitivity analysis. Use them only 
if they are substantively justified -- you can also supply custom
functions for use with this perturbation framework.
\end{Description}
\begin{Usage}
\begin{verbatim}
        PTBmu.gen(reps=1)                       # return a perturbation function that
        PTBmn.gen(reps=1)                       # applies multiple rounds of noise
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{reps}] number of rounds of noise to apply 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Used to generate functions for use in \code{\LinkA{perturb}{perturb}}
\end{Details}
\begin{Value}
Returns a function of the form \code{\LinkA{PTBn}{PTBn}} or 
\code{\LinkA{PTBi}{PTBi}}, with the modification that \emph{reps} 
rounds of noise are applied for each perturbation.
\end{Value}
\begin{Author}\relax
Micah Altman
\email{Micah\_Altman@harvard.edu}
\url{http://www.hmdc.harvard.edu/micah_altman/}
\end{Author}
\begin{References}\relax
Altman, M., J. Gill and M. P. McDonald.  2003.  \emph{Numerical Issues in Statistical
Computing for the Social Scientist}.  John Wiley \& Sons.
\url{http://www.hmdc.harvard.edu/numerical_issues/}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{perturb}{perturb}}, \code{\LinkA{PTBi}{PTBi}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
        x=1:1000
        f1=PTBmu.gen(); # should be roughly equivalent to PTBu() 
        x.u = f1(x,size=1)
        mean(x-x.u)  #should be small
        f2=PTBmu.gen(reps=100); # multiple disturbances tend to cancel eachother out
        x.u2 = f2(x,size=1)
        mean(x-x.u2)  #should be smaller 
\end{ExampleCode}
\end{Examples}

