\hypertarget{RND_8c}{
\section{RND.c File Reference}
\label{RND_8c}\index{RND.c@{RND.c}}
}
Random Number Distributions, interface.  


{\tt \#include \char`\"{}RND.h\char`\"{}}\par
{\tt \#include $<$math.h$>$}\par


Include dependency graph for RND.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=70pt]{RND_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned int \hyperlink{RND_8c_a0}{RND\_\-\_\-lc0\_\-args} (unsigned int prv, unsigned int a, unsigned int c)
\begin{CompactList}\small\item\em Produces a random number in the range 0 - 2$\ast$$\ast$32-1 using a linear congruent method. \item\end{CompactList}\item 
void \hyperlink{RND_8c_a1}{RND\_\-lc0\_\-init} (\hyperlink{struct__RND__lc0}{RND\_\-lc0} $\ast$ctx, unsigned int seed)
\begin{CompactList}\small\item\em Init. \item\end{CompactList}\item 
unsigned int \hyperlink{RND_8c_a2}{RND\_\-lc0\_\-gen} (\hyperlink{struct__RND__lc0}{RND\_\-lc0} $\ast$ctx)
\begin{CompactList}\small\item\em Produces a random number in the range 0 - 2$\ast$$\ast$32-1 using a linear congruent method. \item\end{CompactList}\item 
int \hyperlink{RND_8c_a3}{RND\_\-normal\_\-lc0\_\-gen} (\hyperlink{struct__RND__normal__lc0}{RND\_\-normal\_\-lc0} $\ast$ctx)
\begin{CompactList}\small\item\em Produces a normal distribution. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Random Number Distributions, interface. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\subsection{Function Documentation}
\hypertarget{RND_8c_a0}{
\index{RND.c@{RND.c}!RND__lc0_args@{RND\_\-\_\-lc0\_\-args}}
\index{RND__lc0_args@{RND\_\-\_\-lc0\_\-args}!RND.c@{RND.c}}
\subsubsection[RND\_\-\_\-lc0\_\-args]{\setlength{\rightskip}{0pt plus 5cm}unsigned int RND\_\-\_\-lc0\_\-args (unsigned int {\em prv}, unsigned int {\em a}, unsigned int {\em c})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{RND_8c_a0}


Produces a random number in the range 0 - 2$\ast$$\ast$32-1 using a linear congruent method. 

\begin{Desc}
\item[Returns:]A random number in the range 0 - 2$\ast$$\ast$32 - 1\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em prv}]The previous random number \item[{\em a}]The multiplier \item[{\em c}]The additive factor\end{description}
\end{Desc}
One should scale this number by a suitable factor to produce the desired distribution. No should not use a modulus function. For example, do not do



\footnotesize\begin{verbatim}      r = RND__lc0_args (...) % 256;
\end{verbatim}\normalsize


To produce a number from 0 - 255. Rather do



\footnotesize\begin{verbatim}     r = RND__lco_args (...) >> 24;
\end{verbatim}\normalsize
\hypertarget{RND_8c_a2}{
\index{RND.c@{RND.c}!RND_lc0_gen@{RND\_\-lc0\_\-gen}}
\index{RND_lc0_gen@{RND\_\-lc0\_\-gen}!RND.c@{RND.c}}
\subsubsection[RND\_\-lc0\_\-gen]{\setlength{\rightskip}{0pt plus 5cm}unsigned int RND\_\-lc0\_\-gen (\hyperlink{struct__RND__lc0}{RND\_\-lc0} $\ast$ {\em ctx})}}
\label{RND_8c_a2}


Produces a random number in the range 0 - 2$\ast$$\ast$32-1 using a linear congruent method. 

\begin{Desc}
\item[Returns:]A random number in the range 0 - 2$\ast$$\ast$32 - 1\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctx}]Context parameter\end{description}
\end{Desc}
One should scale this number by a suitable factor to produce the desired distribution. No should not use a modulus function. For example, do not do



\footnotesize\begin{verbatim}      r = RND__lc0_args (...) % 256;
\end{verbatim}\normalsize


To produce a number from 0 - 255. Rather do



\footnotesize\begin{verbatim}     r = RND__lco_args (...) >> 24;
\end{verbatim}\normalsize


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=132pt]{RND_8c_a2_cgraph}
\end{center}
\end{figure}
\hypertarget{RND_8c_a1}{
\index{RND.c@{RND.c}!RND_lc0_init@{RND\_\-lc0\_\-init}}
\index{RND_lc0_init@{RND\_\-lc0\_\-init}!RND.c@{RND.c}}
\subsubsection[RND\_\-lc0\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void RND\_\-lc0\_\-init (\hyperlink{struct__RND__lc0}{RND\_\-lc0} $\ast$ {\em ctx}, unsigned int {\em seed})}}
\label{RND_8c_a1}


Init. 

\begin{Desc}
\item[Returns:]Init random number struct to suggested values\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctx}]Context parameter \item[{\em seed}]random number seed \end{description}
\end{Desc}
\hypertarget{RND_8c_a3}{
\index{RND.c@{RND.c}!RND_normal_lc0_gen@{RND\_\-normal\_\-lc0\_\-gen}}
\index{RND_normal_lc0_gen@{RND\_\-normal\_\-lc0\_\-gen}!RND.c@{RND.c}}
\subsubsection[RND\_\-normal\_\-lc0\_\-gen]{\setlength{\rightskip}{0pt plus 5cm}unsigned int RND\_\-normal\_\-lc0\_\-gen (\hyperlink{struct__RND__normal__lc0}{RND\_\-normal\_\-lc0} $\ast$ {\em ctx})}}
\label{RND_8c_a3}


Produces a normal distribution. 

\begin{Desc}
\item[Returns:]A random number drawn from a normal distribution\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctx}]Context parameter \end{description}
\end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=153pt]{RND_8c_a3_cgraph}
\end{center}
\end{figure}
