Skip to content

Instantly share code, notes, and snippets.

@YukiSakamoto
Created July 30, 2012 13:29
Show Gist options
  • Save YukiSakamoto/3206906 to your computer and use it in GitHub Desktop.
Save YukiSakamoto/3206906 to your computer and use it in GitHub Desktop.
Mersenne Twister Algorithm
#include <iostream>
#include <boost/random.hpp>
using namespace boost;
int main(void)
{
boost::mt19937 gen(static_cast<double>(time(0)));
boost::uniform_real<> range(0, 1);
boost::variate_generator< boost::mt19937, boost::uniform_real<> > random(gen, range);
for(int i(0); i < 128; i++) {
std::cout << random() << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment