24 September 2008

Random number generators

I spent a good deal of time today -- way more than I should have -- looking at random number generators, specifically the ones in Boost (which are aliased by its std::tr1 deal). It turns out, based on my limited testing, that they're incredibly slow. The Mersenne Twister here is up to five times as fast. If I ever write a real Monte Carlo program, I definitely won't want to make my program five times slower if I don't have to.

I also spent about an hour trying to find where in my header files I'd somehow done "using namespace std", or if I'd accidentally included a instead of a , because somehow sqrt and rand were in the global namespace. It turns out that gcc's implementation automatically makes all the math functions global. Boo.

0 comments:

Post a Comment