Boost random number generator

后端 未结 3 686
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 14:36

Does anyone have a favorite boost random number generator and can you explain a little on how to implement it into code. I am trying to get the mersenne twister to work and

3条回答
  •  遥遥无期
    2020-11-27 15:26

    I found this link which gives a good overview of properties of different random number generators. I have copied the table from above link for convenience:

    +-----------------------+-------------------+-----------------------------+------------------------+
    |       generator       | length of cycle   | approx. memory requirements | approx. relative speed |
    +-----------------------+-------------------+-----------------------------+------------------------+
    | minstd_rand           | 2^31-2            | sizeof(int32_t)             |                     40 |
    | rand48                | 2^48-1            | sizeof(uint64_t)            |                     80 |
    | lrand48 (C library)   | 2^48-1            | -                           |                     20 |
    | ecuyer1988            | approx. 2^61      | 2*sizeof(int32_t)           |                     20 |
    | kreutzer1986          | ?                 | 1368*sizeof(uint32_t)       |                     60 |
    | hellekalek1995        | 2^31-1            | sizeof(int32_t)             |                      3 |
    | mt11213b              | 2^11213-1         | 352*sizeof(uint32_t)        |                    100 |
    | mt19937               | 2^19937-1         | 625*sizeof(uint32_t)        |                    100 |
    | lagged_fibonacci607   | approx. 2^32000   | 607*sizeof(double)          |                    150 |
    | lagged_fibonacci1279  | approx. 2^67000   | 1279*sizeof(double)         |                    150 |
    | lagged_fibonacci2281  | approx. 2^120000  | 2281*sizeof(double)         |                    150 |
    | lagged_fibonacci3217  | approx. 2^170000  | 3217*sizeof(double)         |                    150 |
    | lagged_fibonacci4423  | approx. 2^230000  | 4423*sizeof(double)         |                    150 |
    | lagged_fibonacci9689  | approx. 2^510000  | 9689*sizeof(double)         |                    150 |
    | lagged_fibonacci19937 | approx. 2^1050000 | 19937*sizeof(double)        |                    150 |
    | lagged_fibonacci23209 | approx. 2^1200000 | 23209*sizeof(double)        |                    140 |
    | lagged_fibonacci44497 | approx. 2^2300000 | 44497*sizeof(double)        |                     60 |
    +-----------------------+-------------------+-----------------------------+------------------------+
    

    length of cycle: length of random number sequence before it starts repeating

提交回复
热议问题