IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2045


Ignore:
Timestamp:
Oct 11, 2004, 11:49:56 AM (22 years ago)
Author:
Paul Price
Message:

Adding random numbers. Removed psGaussianDev, and altered psLibInit.

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/ChangeLogSDRS.tex

    r2044 r2045  
    1 %%% $Id: ChangeLogSDRS.tex,v 1.31 2004-10-11 19:54:50 price Exp $
     1%%% $Id: ChangeLogSDRS.tex,v 1.32 2004-10-11 21:49:56 price Exp $
    22
    33\subsection{Changes from version 00 to version 01}
     
    335335\item Added \code{psTimeAlloc}.
    336336\item Adding \code{errors} to \code{psVectorStats}.
     337\item Adding \code{psRandom}, with three distributions (uniform,
     338  Gaussian, Poisson).  This obsoletes \code{psGaussianDev}, and
     339  impacts \code{psLibInit} (no longer needs to seed the RNG).
    337340\end{itemize}
  • trunk/doc/pslib/psLibSDRS.tex

    r2038 r2045  
    1 %%% $Id: psLibSDRS.tex,v 1.133 2004-10-09 01:37:41 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.134 2004-10-11 21:49:44 price Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    175175\begin{itemize}
    176176\item Set the error codes for PSLib.
    177 \item Seed the random number generator.
    178177\item Read the \code{psTime} configuration file (\code{timeConfig})
    179178  and set up the appropriate \code{psTimeTable}s and predictions.
     
    182181The prototype is:
    183182\begin{verbatim}
    184 void psLibInit(bool predictable, const char *timeConfig);
    185 \end{verbatim}
    186 
    187 If \code{predictable} is \code{true}, then the random number generator
    188 shall be seeded with a value that does not vary (allowing bugs relying
    189 on random numbers to be reproduced); otherwise, the random number
    190 generator shall be seeded from \code{/dev/random} if it exists,
    191 otherwise from the system clock.
     183void psLibInit(const char *timeConfig);
     184\end{verbatim}
    192185
    193186\code{timeConfig} specifies the filename of the configuration file
     
    21672160Gaussians are used extensively in any data-analysis system, in
    21682161particular to represent a real population distribution.  We require a
    2169 function to evaluate a Gaussian for a given coordinate and one which
    2170 generates a Gaussian deviate; a collection of data points whose
    2171 distribution obeys a specified Gaussian.
     2162function to evaluate a Gaussian for a given coordinate.
    21722163
    21732164The Gaussian evaluation is provide by:
     
    21852176In the case of the non-normalized Gaussian, the leading coefficient is
    21862177dropped.
    2187 
    2188 A vector with a specified Gaussian deviate distribution is provide by:
    2189 \begin{verbatim}
    2190 psVector *psGaussianDev(float mean, float sigma, int Npts);
    2191 \end{verbatim}
    2192 which generates a vector (type \code{psF32}) of \code{Npts} elements
    2193 whose distribution has the given \code{mean} and \code{sigma}.
    21942178
    21952179%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    31873171In the event that \code{out} is \code{NULL}, a new \code{psImage}
    31883172shall be allocated and returned.
     3173
     3174%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3175
     3176\subsection{Random Numbers}
     3177
     3178Many applications involve random numbers, with the particular
     3179distribution depending upon the application.  We will wrap the GSL
     3180implementation.
     3181
     3182We define a \code{psRandom} type, which will allow us to carry around
     3183pre-computed random numbers, if required.  For the time being, we only
     3184specify a single randon number generator (RNG) in \code{psRandomType}
     3185(that provided by \code{gsl_rng_taus}), but we leave this open to
     3186expansion in the future, depending upon user requirements.
     3187
     3188\begin{verbatim}
     3189typedef enum {
     3190    PS_RANDOM_TAUS                      ///< A maximally equidistributed combined Tausworthe generator
     3191} psRandomType;
     3192
     3193typedef struct {
     3194    psRandomType type;                  ///< The type of RNG
     3195    gsl_rng *gsl;                       ///< The RNG itself
     3196} psRandom;
     3197\end{verbatim}
     3198
     3199We require the ability to seed the random number generator (RNG) with
     3200a known value, so that bugs in modules which rely upon random numbers
     3201may be reproduced.
     3202
     3203\begin{verbatim}
     3204psRandom *psRandomAlloc(psRandomType type, unsigned long seed);
     3205void psRandomReset(psRandom *rand, unsigned long seed);
     3206\end{verbatim}
     3207
     3208\code{psRandomAlloc} shall construct a new instance of \code{psRandom}
     3209of the given \code{type}, and seed it with the given \code{seed}.  The
     3210\code{seed} is specified as an \code{unsigned long} so that the system
     3211clock may be used to set it.  If the \code{seed} is zero, then the RNG
     3212shall be seeded from \code{/dev/random} if it exists, or otherwise
     3213from the system clock, and the particular seed shall be printed using
     3214\code{psLogMsg} with a level of \code{PS_LOG_INFO}.
     3215
     3216\begin{verbatim}
     3217double psRandomUniform(const psRandom *r);
     3218double psRandomGaussian(const psRandom *r);
     3219double psRandomPoisson(const psRandom *r, double mean);
     3220\end{verbatim}
     3221
     3222\code{psRandomUniform} shall return random numbers uniformly
     3223distributed on $[0,1)$, using \code{gsl_rng_uniform}.
     3224\code{psRandomGaussian} shall return random numbers distributed on a
     3225Gaussian deviate, $N(0,1)$, using \code{gsl_ran_gaussian}.
     3226\code{psRandomPoisson} shall return random numbers distributed on a
     3227Poisson distribution with the given \code{mean} using
     3228\code{gsl_ran_poisson}.
    31893229
    31903230%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.