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



This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=108pt]{RND_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__RND__lc0}{\_\-RND\_\-lc0}
\begin{CompactList}\small\item\em Structure giving the parameters of a simply linear congruent random number generator. \item\end{CompactList}\item 
struct \hyperlink{struct__RND__normal__lc0}{\_\-RND\_\-normal\_\-lc0}
\begin{CompactList}\small\item\em Structure giving the parameters of a simple normal distribution random number generator. \item\end{CompactList}\item 
struct \hyperlink{struct__RND__poisson__lc0}{\_\-RND\_\-poisson\_\-lc0}
\begin{CompactList}\small\item\em Structure giving the parameters of a poisson distribution. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef \hyperlink{struct__RND__lc0}{\_\-RND\_\-lc0} \hyperlink{RND_8h_a0}{RND\_\-lc0}
\begin{CompactList}\small\item\em Typedef for the struct {\em \hyperlink{struct__RND__lc0}{\_\-RND\_\-lc0}\/}. \item\end{CompactList}\item 
typedef \hyperlink{struct__RND__normal__lc0}{\_\-RND\_\-normal\_\-lc0} \hyperlink{RND_8h_a1}{RND\_\-normal\_\-lc0}
\begin{CompactList}\small\item\em Typedef for the struct {\em \_\-RND\_\-normal0\/}. \item\end{CompactList}\item 
typedef \hyperlink{struct__RND__poisson__lc0}{\_\-RND\_\-poisson\_\-lc0} \hyperlink{RND_8h_a2}{RND\_\-poisson\_\-lc0}
\begin{CompactList}\small\item\em Typedef for the struct {\em \_\-LSI\_\-poisson\_\-lco\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{RND_8h_a3}{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_8h_a4}{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_8h_a5}{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}


\footnotesize\begin{verbatim}    CVS $Id: RND.h,v 1.1 2004/07/19 20:04:00 ebacho Exp $
\end{verbatim}
\normalsize


\begin{Desc}
\item[SYNOPSIS]Defines the interfaces for a number of common random number distributions.\end{Desc}
The casual reader may well ask why provide these here when such objects are readily available on most platforms. The answer is that the algorithms generating these distributions are fully exposed so that they may be readily implemented on a more than one platforms. This means, that given the algorithm and its parameterization, the exact distribution may be generated on any machine. This is valuable when. for example, one generates test patterns using these algorithms and ships the results to another machine for comparison. If the algorithm and its parameterization are stored, the remote machine can exactly reproduce and check the distribution.

\subsection{Typedef Documentation}
\hypertarget{RND_8h_a0}{
\index{RND.h@{RND.h}!RND_lc0@{RND\_\-lc0}}
\index{RND_lc0@{RND\_\-lc0}!RND.h@{RND.h}}
\subsubsection[RND\_\-lc0]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__RND__lc0}{RND\_\-lc0}}}
\label{RND_8h_a0}


Typedef for the struct {\em \hyperlink{struct__RND__lc0}{\_\-RND\_\-lc0}\/}. 

This random number generator uses the formula

x\_\-\{n+1\} = (a x\_\-n + c)

Suggested choices are

\begin{itemize}
\item a = 69069\item c = 1\end{itemize}


The seed value must be odd. It has been selected since it is relatively fast, involving only a multiply and an addition. Probably not a great choice for real math, but for generating random patterns, not bad\hypertarget{RND_8h_a1}{
\index{RND.h@{RND.h}!RND_normal_lc0@{RND\_\-normal\_\-lc0}}
\index{RND_normal_lc0@{RND\_\-normal\_\-lc0}!RND.h@{RND.h}}
\subsubsection[RND\_\-normal\_\-lc0]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__RND__normal__lc0}{RND\_\-normal\_\-lc0}}}
\label{RND_8h_a1}


Typedef for the struct {\em \_\-RND\_\-normal0\/}. 

This is a very simplistic generator, just adding 6 random numbers from the LC generator\hypertarget{RND_8h_a2}{
\index{RND.h@{RND.h}!RND_poisson_lc0@{RND\_\-poisson\_\-lc0}}
\index{RND_poisson_lc0@{RND\_\-poisson\_\-lc0}!RND.h@{RND.h}}
\subsubsection[RND\_\-poisson\_\-lc0]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__RND__poisson__lc0}{RND\_\-poisson\_\-lc0}}}
\label{RND_8h_a2}


Typedef for the struct {\em \_\-LSI\_\-poisson\_\-lco\/}. 

This is just a scaled exponential distribution, using a linear congruent

\subsection{Function Documentation}
\hypertarget{RND_8h_a4}{
\index{RND.h@{RND.h}!RND_lc0_gen@{RND\_\-lc0\_\-gen}}
\index{RND_lc0_gen@{RND\_\-lc0\_\-gen}!RND.h@{RND.h}}
\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_8h_a4}


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
\hypertarget{RND_8h_a3}{
\index{RND.h@{RND.h}!RND_lc0_init@{RND\_\-lc0\_\-init}}
\index{RND_lc0_init@{RND\_\-lc0\_\-init}!RND.h@{RND.h}}
\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_8h_a3}


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_8h_a5}{
\index{RND.h@{RND.h}!RND_normal_lc0_gen@{RND\_\-normal\_\-lc0\_\-gen}}
\index{RND_normal_lc0_gen@{RND\_\-normal\_\-lc0\_\-gen}!RND.h@{RND.h}}
\subsubsection[RND\_\-normal\_\-lc0\_\-gen]{\setlength{\rightskip}{0pt plus 5cm}int RND\_\-normal\_\-lc0\_\-gen (\hyperlink{struct__RND__normal__lc0}{RND\_\-normal\_\-lc0} $\ast$ {\em ctx})}}
\label{RND_8h_a5}


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}
