Fast real valued random generator in java

后端 未结 6 1495
借酒劲吻你
借酒劲吻你 2020-12-31 12:51

java.util.Random.nextDouble() is slow for me and I need something really fast.

I did some google search and I\'ve found only integers based fast random generators.

6条回答
  •  粉色の甜心
    2020-12-31 13:25

    Note that all these solutions miss a fundamental fact (that I wasn't aware of up to a few weeks ago): passing from 64 bits to a double using a multiplication is a major loss of time. The implementation of xorshift128+ and xorshift1024+ in the DSI utilities (http://dsiutils.di.unimi.it/) use direct bit manipulation and the results are impressive.

    See the benchmarks for nextDouble() at

    http://dsiutils.di.unimi.it/docs/it/unimi/dsi/util/package-summary.html#package.description

    and the quality reported at

    http://prng.di.unimi.it/

提交回复
热议问题