|
1 | 1 | Performance
|
2 | 2 | -----------
|
3 | 3 |
|
| 4 | +.. py:module:: randomstate |
| 5 | +
|
| 6 | +Recommendation |
| 7 | +************** |
| 8 | +The recommended generator for single use is `xoroshiro128+` |
| 9 | +(:class:`~randomstate.prng.xoroshiro128plus`). The recommended generator |
| 10 | +for use in large-scale parallel applications is |
| 11 | +`xorshift1024*` (:class:`~randomstate.prng.xorshift1024`) |
| 12 | +where the `jump` method is used to advance the state. |
| 13 | + |
| 14 | +Timings |
| 15 | +******* |
| 16 | + |
| 17 | +The timings below are ns/random value. The fastest generator is the |
| 18 | +raw generator (`random_raw`) which does not make any transformation |
| 19 | +to the underlying random value. `xoroshiro128+` is the fastest, followed by |
| 20 | +`xorshift1024*` and the two SIMD aware MT generators. The original MT19937 |
| 21 | +generator is much slower since it requires 2 32-bit values to equal the output |
| 22 | +of the faster generators. |
| 23 | + |
| 24 | +Integer performance has a similar ordering although `dSFMT` is slower since |
| 25 | +it generates 53-bit floating point values rather than integer values. On the |
| 26 | +other hand, it is very fast for uniforms, although slower than `xoroshiro128+`. |
| 27 | + |
| 28 | +The patterm is similar for other, more complex generators. The normal |
| 29 | +performance of NumPy's MT19937 is much lower than the other since it |
| 30 | +uses the Box-Muller transformation rather than the Ziggurat generator. |
| 31 | + |
| 32 | +.. csv-table:: |
| 33 | + :header: ,NumPy MT19937,MT19937,SFMT,dSFMT,xoroshiro128+,xorshift1024,PCG64 |
| 34 | + :widths: 14,14,14,14,14,14,14,14 |
| 35 | + |
| 36 | + Raw,,5.07,1.98,1.91,1.08,1.49,3.16 |
| 37 | + Random Integers,4.84,3.32,2.36,3.36,1.99,2.53,2.32 |
| 38 | + Uniforms,10.41,6.53,2.7,2.7,1.58,2.31,2.47 |
| 39 | + Normal,69.4,15.34,9.93,11.57,9.56,11.69,11.64 |
| 40 | + Complex Normal,,40.57,28.05,31.91,25.8,31.9,31.86 |
| 41 | + Binomial,77.46,71.08,65.77,65.71,66.18,67.23,69.51 |
| 42 | + Gamma,107.42,97.66,86.5,86.09,82.31,87.42,86.41 |
| 43 | + Exponential,112.54,104.16,96.23,95.22,93.98,98.15,98.36 |
| 44 | + Laplace,116.09,114.2,102.35,100.21,100.5,105.9,104.82 |
| 45 | + Poisson,151.65,135.11,105.1,103.89,102.43,116.29,114.34 |
| 46 | + Neg. Binomial,476.34,453.07,429.23,426.31,423.45,429.81,430.05 |
| 47 | + Multinomial,1166.63,1146.25,1111.39,1097.51,1095.43,1103.77,1109.79 |
| 48 | + |
| 49 | +The next table presents the performance relative to `xoroshiro128+`. The overall |
| 50 | +performance was computed using a geometric mean. |
| 51 | + |
4 | 52 | .. csv-table::
|
5 |
| - :header: ,NumPy MT19937,MT19937,SFMT,dSFMT,xoroshirt128+,xorshift1024,PCG64 |
| 53 | + :header: ,NumPy MT19937,MT19937,SFMT,dSFMT,xoroshiro128+,xorshift1024,PCG64 |
6 | 54 | :widths: 14,14,14,14,14,14,14,14
|
7 | 55 |
|
8 |
| - Random Integers,16.05,8.68,15.92,9.08,16.97,16.19,17.76 |
9 |
| - Raw,,12.11,9.61,15.79,12.37,16.32,24.21 |
10 |
| - Uniforms,21.58,18.82,11.18,7.5,11.32,13.55,22.9 |
11 |
| - Normal,54.74,28.82,11.84,17.5,18.03,22.63,26.19 |
12 |
| - Exponential,25.53,37.37,16.71,15.66,26.58,32.37,36.58 |
13 |
| - Laplace,45.66,35.66,47.37,40.27,43.56,31.58,34.87 |
14 |
| - Complex Normal,,52.5,63.03,75.66,52.5,42.5,76.45 |
15 |
| - Gamma,93.03,63.29,66.32,46.84,70.92,76.71,103.56 |
16 |
| - Poisson,83.16,116.85,65.27,60.92,64.87,74.61,112.9 |
17 |
| - Binomial,97.77,90.93,110.01,104.87,104.48,104.61,94.87 |
18 |
| - Neg. Binomial,290.81,201.85,218.83,211.99,214.35,230.01,280.67 |
19 |
| - Multinomial,586.87,597.8,456.21,535.16,547.66,562.27,610.95 |
| 56 | + Raw,,4.69,1.83,1.77,1.0,1.38,2.93 |
| 57 | + Random Integers,2.43,1.67,1.19,1.69,1.0,1.27,1.17 |
| 58 | + Uniforms,6.59,4.13,1.71,1.71,1.0,1.46,1.56 |
| 59 | + Normal,7.26,1.6,1.04,1.21,1.0,1.22,1.22 |
| 60 | + Complex Normal,,1.57,1.09,1.24,1.0,1.24,1.23 |
| 61 | + Binomial,1.17,1.07,0.99,0.99,1.0,1.02,1.05 |
| 62 | + Gamma,1.31,1.19,1.05,1.05,1.0,1.06,1.05 |
| 63 | + Exponential,1.2,1.11,1.02,1.01,1.0,1.04,1.05 |
| 64 | + Laplace,1.16,1.14,1.02,1.0,1.0,1.05,1.04 |
| 65 | + Poisson,1.48,1.32,1.03,1.01,1.0,1.14,1.12 |
| 66 | + Neg. Binomial,1.12,1.07,1.01,1.01,1.0,1.02,1.02 |
| 67 | + Multinomial,1.06,1.05,1.01,1.0,1.0,1.01,1.01 |
| 68 | + Overall,1.84,1.55,1.14,1.19,1.0,1.15,1.22 |
| 69 | + |
| 70 | + |
| 71 | +.. note:: |
| 72 | + |
| 73 | + All timings were taken using Linux and gcc 5.4 on a i7-5600U processor. |
0 commit comments