psRandom.h

Go to the documentation of this file.
00001 /* @file psRandom.h
00002  * @brief Random Number Generators
00003  *
00004  * This file will hold the prototypes for procedures which allocate, free,
00005  * and evaluate random number Generators.
00006  *
00007  * @author GLG, MHPCC
00008  *
00009  * @version $Revision: 1.8 $ $Name:  $
00010  * @date $Date: 2007/01/23 22:47:23 $
00011  *
00012  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00013  */
00014 
00015 #ifndef PS_RANDOM_H
00016 #define PS_RANDOM_H
00017 
00018 /// @addtogroup MathOps Mathematical Operations
00019 /// @{
00020 
00021 #include <stdio.h>
00022 #include <stdbool.h>
00023 #include <float.h>
00024 #include <math.h>
00025 
00026 #include "psVector.h"
00027 #include "psScalar.h"
00028 #include <gsl/gsl_rng.h>
00029 #include <gsl/gsl_randist.h>
00030 
00031 /** Enumeration containing a flag for psRandom types.  */
00032 typedef enum {
00033     PS_RANDOM_TAUS                     ///< A maximally equidistributed combined Tausworthe generator.
00034 } psRandomType;
00035 
00036 /** Data structure for psRandom.
00037  *  Contains information on the psRandom type and GNU Scientific Library random number generator.
00038  */
00039 typedef struct
00040 {
00041     psRandomType type;                 ///< The type of RNG
00042     gsl_rng *gsl;                      ///< The RNG itself
00043 }
00044 psRandom;
00045 
00046 psU64 p_psRandomGetSystemSeed();
00047 
00048 /** Allocates a psRandom struct.
00049  *  
00050  *  @return psRandom*:    A new psRandom structure.
00051  */
00052 psRandom *psRandomAlloc(
00053     psRandomType type,                 ///< The type of RNG
00054     unsigned long seed                 ///< Known value with which to seed the RNG
00055 );
00056 
00057 /** Resets an existing psRandom struct.
00058  *  
00059  *  @return void
00060  */
00061 void psRandomReset(
00062     psRandom *rand,                    ///< Existing psRandom struct to reset
00063     unsigned long seed                 ///< Known value with which to seed the RNG
00064 );
00065 
00066 /** Random number generator based on a uniform distribution on [0,1).
00067  *  Uses gsl_rng_uniform.
00068  *  
00069  *  @return double:     Random number.
00070  */
00071 double psRandomUniform(
00072     const psRandom *r                  ///< psRandom struct for RNG
00073 );
00074 
00075 /** Random number generator based on a Gaussian deviate, N(0,1).
00076  *  Uses gsl_ran_gaussian.
00077  *  
00078  *  @return double:     Random number.
00079  */
00080 double psRandomGaussian(
00081     const psRandom *r                  ///< psRandom struct for RNG
00082 );
00083 
00084 /** Random number generator based on a Gaussian deviate, N(0,1).
00085  *  Uses gsl_ran_gaussian.
00086  *  
00087  *  XXX: I created this since the above psLib spec for p_psRandomGaussian
00088  *  had no argument for sigma.  Verify that with IfA.
00089  *  
00090  *  @return double:     Random number.
00091  */
00092 double p_psRandomGaussian(
00093     const psRandom *r,                  ///< psRandom struct for RNG
00094     double sigma
00095 );
00096 
00097 /** Random number generator based on a Poisson distribution with the given mean.
00098  *  Uses gsl_ran_poisson.
00099  *  
00100  *  @return double:     Random number.
00101  */
00102 double psRandomPoisson(
00103     const psRandom *r,                 ///< psRandom struct for RNG
00104     double mean                         ///< Mean value
00105 );
00106 
00107 /// @}
00108 #endif // #ifndef PS_RANDOM_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1