Boost C++ Libraries: Ticket #6135: Significant speed-up in gamma rng by switching from Knuth method to Marsaglia and Tsang (2000) https://svn.boost.org/trac10/ticket/6135 <p> When compared to the GNU Scientific Library (GSL), the generation of Gamma-distributed random numbers is very slow in Boost. A simple test, generating 100000000 random numbers, reveals </p> <p> GSL : 22.3233 MSamples/s<br /> Boost : 5.41275 MSamples/s </p> <p> where MSamples/s is million samples per second. The difference is due to Boost using the Knuth method, whereas the GSL implements a newer method by Marsaglia and Tsang (2000). </p> <p> With the attached patch, which implements the newer method, the performance improves to </p> <p> GSL : 22.7472 MSamples/s<br /> Boost : 14.5018 MSamples/s </p> <p> The remaining difference between Boost and GSL can be traced back to GSL using Zigguraut rather than Box-Muller to generate Normal random numbers. At some point I might submit a patch for normal_distribution.hpp that implements the Zigguraut algorithm. </p> <p> The attached patch exactly follows gsl_ran_gamma of GSL v1.15 (gsl-1.15/randdist/gamma.c) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6135 Trac 1.4.3 Jan Drugowitsch <jdrugo@…> Thu, 17 Nov 2011 19:00:20 GMT attachment set https://svn.boost.org/trac10/ticket/6135 https://svn.boost.org/trac10/ticket/6135 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gamma_distribution.patch</span> </li> </ul> Ticket