boostで対数正規分布乱数の発生。
g++ test.cpp -L/usr/include/boost/random
test.cpp
#include<boost/random.hpp> #include<stdio.h> #include<stdlib.h> #include<iostream> int main(){ using namespace std; using namespace boost; mt19937 gen(1); lognormal_distribution<> dst(1,1); //normal_distribution<> dst(1,1); //variate_generator<mt19937&,normal_distribution<> > rand(gen,dst); variate_generator<mt19937&,lognormal_distribution<> > rand(gen,dst); int i; for(i=0;i<=10000;i++){ cout << rand() << endl; } }