I've got three questions/comments regarding the Random Number Library: Question (1) --------------------------------------------------------- How about including a facility for generating "antithetic random variates"? (Do a google search if the term is unfamiliar). A partial implementation might be something like the following, (I haven't tried compiling this, so please pardon any syntax errors...): template< class URNG > // Uniform Random Number Generator class antithetic { private: URNG urng; public: explicit antithetic( s ) { urng.seed(s); } // Perhaps not quite right (see question (2) below) typename URNG::result_type operator()() { return URNG::max_value - urng(); } }; Then one would be able to construct two antithetic variates (rng1 & rng2) as follows: mt19937 rng1(seed); antithetic<mt19937> rng2(seed); Question (2) -------------------------------------------------------- Regarding the "uniform_01" generator (and a possible bug in "uniform_in_sphere"). The interval generated by uniform_01 is designed to be the "half-open" interval [0,1). The asymmetry seems unnecessary. How about using the open interval (0,1). I can appreciate that perhaps efficiency is the reason for using the interval [0,1) if one is generating the random floating point numbers by setting the mantissa with a random bit stream. But, consider the following advantage to using (0,1): You would avoid a possible zerodivide in the "uniform_in_sphere" class. Here's my reasoning: Using the current "uniform_01" generator with the half open interval [0,1) the normal_distribution::operator() can return zero. Using my proposed "uniform_01" generator with the open interval (1,1) the normal_distribution::operator() will never return exactly zero. The "zero" return from normal_distribution::operator() could conceivably cause a zerodivide in "uniform_in_sphere". Question (3) -------------------------------------------------------- How about having a boost random number generator whose output would match that of Matlab's random number generator (both uniform and gaussian)? This would be useful in doing sanity tests when porting code to/from Matlab. Here's a link which gives some info on their generators: http://www.mathworks.com/support/solutions/data/8542.shtml
participants (1)
-
tylersc111