Performance ----------- .. py:module:: numpy.random .. currentmodule:: numpy.random Recommendation ************** The recommended generator for single use is :class:`~.xoshiro256.Xoshiro256`. The recommended generator for use in large-scale parallel applications is :class:`~.xoshiro512.Xoshiro512` where the `jumped` method is used to advance the state. For very large scale applications -- requiring 1,000+ independent streams -- is the best choice. For very large scale applications -- requiring 1,000+ independent streams, :class:`~pcg64.PCG64` or :class:`~.philox.Philox` are the best choices. Timings ******* The timings below are the time in ns to produce 1 random value from a specific distribution. The original :class:`~mt19937.MT19937` generator is much slower since it requires 2 32-bit values to equal the output of the faster generators. Integer performance has a similar ordering although `dSFMT` is slower since it generates 53-bit floating point values rather than integer values. The pattern is similar for other, more complex generators. The normal performance of the legacy :class:`~mtrand.RandomState` generator is much lower than the other since it uses the Box-Muller transformation rather than the Ziggurat generator. The performance gap for Exponentials is also large due to the cost of computing the log function to invert the CDF. The column labeled MT19973 is used the same 32-bit generator as :class:`~mtrand.RandomState` but produces random values using :class:`~generator.Generator`. .. csv-table:: :header: ,Xoshiro256**,Xoshiro512**,DSFMT,PCG64,MT19937,Philox,RandomState,ThreeFry :widths: 14,14,14,14,14,14,14,14,14 32-bit Unsigned Ints,2.6,2.9,3.5,3.2,3.3,4.8,3.2,7.6 64-bit Unsigned Ints,3.3,4.3,5.7,4.8,5.7,6.9,5.7,12.8 Uniforms,3.4,4.0,3.2,5.0,7.3,8.0,7.3,12.8 Normals,7.9,9.0,11.8,11.3,13.0,13.7,34.4,18.1 Exponentials,4.7,5.2,7.4,6.7,7.9,8.6,40.3,14.7 Gammas,29.1,27.5,28.5,30.6,34.2,35.1,58.1,47.6 Binomials,22.7,23.1,21.1,25.7,27.7,28.4,25.9,32.1 Laplaces,38.5,38.1,36.9,41.1,44.5,45.4,46.9,50.2 Poissons,46.9,50.9,46.4,58.1,68.4,70.2,86.0,88.2 The next table presents the performance in percentage relative to values generated by the legagy generator, `RandomState(MT19937())`. The overall performance was computed using a geometric mean. .. csv-table:: :header: ,Xoshiro256**,Xoshiro256**,DSFMT,PCG64,MT19937,Philox,ThreeFry :widths: 14,14,14,14,14,14,14,14 32-bit Unsigned Ints,124,113,93,100,99,67,43 64-bit Unsigned Ints,174,133,100,118,100,83,44 Uniforms,212,181,229,147,100,91,57 Normals,438,382,291,304,264,252,190 Exponentials,851,770,547,601,512,467,275 Gammas,200,212,204,190,170,166,122 Binomials,114,112,123,101,93,91,81 Laplaces,122,123,127,114,105,103,93 Poissons,183,169,185,148,126,123,98 Overall,212,194,180,167,145,131,93 .. note:: All timings were taken using Linux on a i5-3570 processor.