Changeset 2045 for trunk/doc/pslib/psLibSDRS.tex
- Timestamp:
- Oct 11, 2004, 11:49:56 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r2038 r2045 1 %%% $Id: psLibSDRS.tex,v 1.13 3 2004-10-09 01:37:41price Exp $1 %%% $Id: psLibSDRS.tex,v 1.134 2004-10-11 21:49:44 price Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 175 175 \begin{itemize} 176 176 \item Set the error codes for PSLib. 177 \item Seed the random number generator.178 177 \item Read the \code{psTime} configuration file (\code{timeConfig}) 179 178 and set up the appropriate \code{psTimeTable}s and predictions. … … 182 181 The prototype is: 183 182 \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. 183 void psLibInit(const char *timeConfig); 184 \end{verbatim} 192 185 193 186 \code{timeConfig} specifies the filename of the configuration file … … 2167 2160 Gaussians are used extensively in any data-analysis system, in 2168 2161 particular 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. 2162 function to evaluate a Gaussian for a given coordinate. 2172 2163 2173 2164 The Gaussian evaluation is provide by: … … 2185 2176 In the case of the non-normalized Gaussian, the leading coefficient is 2186 2177 dropped. 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} elements2193 whose distribution has the given \code{mean} and \code{sigma}.2194 2178 2195 2179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 3187 3171 In the event that \code{out} is \code{NULL}, a new \code{psImage} 3188 3172 shall be allocated and returned. 3173 3174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3175 3176 \subsection{Random Numbers} 3177 3178 Many applications involve random numbers, with the particular 3179 distribution depending upon the application. We will wrap the GSL 3180 implementation. 3181 3182 We define a \code{psRandom} type, which will allow us to carry around 3183 pre-computed random numbers, if required. For the time being, we only 3184 specify a single randon number generator (RNG) in \code{psRandomType} 3185 (that provided by \code{gsl_rng_taus}), but we leave this open to 3186 expansion in the future, depending upon user requirements. 3187 3188 \begin{verbatim} 3189 typedef enum { 3190 PS_RANDOM_TAUS ///< A maximally equidistributed combined Tausworthe generator 3191 } psRandomType; 3192 3193 typedef struct { 3194 psRandomType type; ///< The type of RNG 3195 gsl_rng *gsl; ///< The RNG itself 3196 } psRandom; 3197 \end{verbatim} 3198 3199 We require the ability to seed the random number generator (RNG) with 3200 a known value, so that bugs in modules which rely upon random numbers 3201 may be reproduced. 3202 3203 \begin{verbatim} 3204 psRandom *psRandomAlloc(psRandomType type, unsigned long seed); 3205 void psRandomReset(psRandom *rand, unsigned long seed); 3206 \end{verbatim} 3207 3208 \code{psRandomAlloc} shall construct a new instance of \code{psRandom} 3209 of 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 3211 clock may be used to set it. If the \code{seed} is zero, then the RNG 3212 shall be seeded from \code{/dev/random} if it exists, or otherwise 3213 from 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} 3217 double psRandomUniform(const psRandom *r); 3218 double psRandomGaussian(const psRandom *r); 3219 double psRandomPoisson(const psRandom *r, double mean); 3220 \end{verbatim} 3221 3222 \code{psRandomUniform} shall return random numbers uniformly 3223 distributed on $[0,1)$, using \code{gsl_rng_uniform}. 3224 \code{psRandomGaussian} shall return random numbers distributed on a 3225 Gaussian deviate, $N(0,1)$, using \code{gsl_ran_gaussian}. 3226 \code{psRandomPoisson} shall return random numbers distributed on a 3227 Poisson distribution with the given \code{mean} using 3228 \code{gsl_ran_poisson}. 3189 3229 3190 3230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note:
See TracChangeset
for help on using the changeset viewer.
