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