
Hi, I have the following code boost::mt19937 rng; boost::cauchy_distribution< double > cauchy( 0.0 , 0.1 ); for( size_t i=0 ; i<16 ; ++i ) { std::cout << cauchy( rng ) << " "; } which produced this sequence : 76513.4 4.3467e+06 -254805 -1.63299e+06 -6.96405e+06 233243 214884 883827 471904 268253 648798 140314 1.43562e+06 653319 -582905 91567.6 I think these number are much to high. The standard deviation should be 0.1. Does anyone knows what went wrong? Is this my failure? I use boost 1.46 and gcc 4.5.2.

AMDG On 07/13/2011 11:04 AM, Karsten Ahnert wrote:
I have the following code
boost::mt19937 rng; boost::cauchy_distribution< double > cauchy( 0.0 , 0.1 );
for( size_t i=0 ; i<16 ; ++i ) { std::cout << cauchy( rng ) << " "; }
which produced this sequence :
76513.4 4.3467e+06 -254805 -1.63299e+06 -6.96405e+06 233243 214884 883827 471904 268253 648798 140314 1.43562e+06 653319 -582905 91567.6
I think these number are much to high. The standard deviation should be 0.1. Does anyone knows what went wrong? Is this my failure?
I use boost 1.46 and gcc 4.5.2.
This code should work correctly in 1.47. In 1.46 and prior, you need to use variate_generator. boost::variate_generator< boost::mt19937&, boost::cauchy_distribution<double> > gen(rng, cauchy); std::cout << gen() << " "; In Christ, Steven Watanabe

Hi Karsten, hi all,
Maybe the documentation of Boost.Random 1.47 fail in explain the detail of
variate_generator<>, or maybe the design changed dramatically. I'm using
Boost 1.46 and the example Steven gave is how i use the library.
http://www.boost.org/doc/libs/1_46_0/doc/html/boost_random.html
In Boost.Random 1.47 the implementation is different:
http://www.boost.org/doc/libs/1_47_0/doc/html/boost_random.html
Anyway, good to know the new design...
Best Regards,
Júlio.
2011/7/13 Steven Watanabe
AMDG
On 07/13/2011 11:04 AM, Karsten Ahnert wrote:
I have the following code
boost::mt19937 rng; boost::cauchy_distribution< double > cauchy( 0.0 , 0.1 );
for( size_t i=0 ; i<16 ; ++i ) { std::cout << cauchy( rng ) << " "; }
which produced this sequence :
76513.4 4.3467e+06 -254805 -1.63299e+06 -6.96405e+06 233243 214884 883827 471904 268253 648798 140314 1.43562e+06 653319 -582905 91567.6
I think these number are much to high. The standard deviation should be 0.1. Does anyone knows what went wrong? Is this my failure?
I use boost 1.46 and gcc 4.5.2.
This code should work correctly in 1.47. In 1.46 and prior, you need to use variate_generator.
boost::variate_generator< boost::mt19937&, boost::cauchy_distribution<double> > gen(rng, cauchy);
std::cout << gen() << " ";
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

This code should work correctly in 1.47. In 1.46 and prior, you need to use variate_generator.
boost::variate_generator< boost::mt19937&, boost::cauchy_distribution<double> > gen(rng, cauchy);
std::cout << gen() << " ";
Ok, thank you. I had the wrong documentation. Btw. are there any factory functions for the variate_generator? Something like make_variate_generator( rng , cauchy ) which could be nicely use when filling containers with random numbers generate( x.begin() , x.end() , make_variate_generator( rng , cauchy ) );

AMDG On 07/14/2011 09:04 AM, Karsten Ahnert wrote:
Btw. are there any factory functions for the variate_generator? Something like
make_variate_generator( rng , cauchy )
which could be nicely use when filling containers with random numbers
generate( x.begin() , x.end() , make_variate_generator( rng , cauchy ) );
I considered it, but in 1.47, you should be able to use boost::bind(cauchy, boost::ref(rng)) In Christ, Steven Watanabe
participants (3)
-
Júlio Hoffimann
-
Karsten Ahnert
-
Steven Watanabe