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


{\tt \#include $<$RND.h$>$}\par
{\tt \#include $<$math.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
static unsigned int \hyperlink{RND_8c_fa231031da391dd8a9bf85b7e7fbaa80}{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_644db7257f647b3d2dff1a8f99ca928e}{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_6360fc2da822cce796b8a04889a71c8b}{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_84b59df67347dacbfea9dc4cbf126a9d}{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_fa231031da391dd8a9bf85b7e7fbaa80}{
\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_fa231031da391dd8a9bf85b7e7fbaa80}


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



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



To produce a number from 0 - 255. Rather do



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

 

Referenced by RND\_\-lc0\_\-gen(), and RND\_\-normal\_\-lc0\_\-gen().\hypertarget{RND_8c_6360fc2da822cce796b8a04889a71c8b}{
\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 ({\bf RND\_\-lc0} $\ast$ {\em ctx})}}
\label{RND_8c_6360fc2da822cce796b8a04889a71c8b}


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



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



To produce a number from 0 - 255. Rather do



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

 

References \_\-RND\_\-lc0::a, \_\-RND\_\-lc0::c, RND\_\-\_\-lc0\_\-args(), and \_\-RND\_\-lc0::seed.\hypertarget{RND_8c_644db7257f647b3d2dff1a8f99ca928e}{
\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 ({\bf RND\_\-lc0} $\ast$ {\em ctx}, \/  unsigned int {\em seed})}}
\label{RND_8c_644db7257f647b3d2dff1a8f99ca928e}


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}


References \_\-RND\_\-lc0::a, \_\-RND\_\-lc0::c, and \_\-RND\_\-lc0::seed.

Referenced by SSRSIM\_\-init().\hypertarget{RND_8c_84b59df67347dacbfea9dc4cbf126a9d}{
\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 ({\bf RND\_\-normal\_\-lc0} $\ast$ {\em ctx})}}
\label{RND_8c_84b59df67347dacbfea9dc4cbf126a9d}


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}


References \_\-RND\_\-lc0::a, \_\-RND\_\-lc0::c, \_\-RND\_\-normal\_\-lc0::lc0, \_\-RND\_\-normal\_\-lc0::mean, RND\_\-\_\-lc0\_\-args(), \_\-RND\_\-lc0::seed, and \_\-RND\_\-normal\_\-lc0::sigma.