据我所知,Java使用线性同余发生器。我的问题是 - 什么是产生一个随机数的复杂?你如何进行此类分析?
I am aware that Java uses a Linear congruential generator. My question is- what is the complexity of generating a random number? How do you perform such analyses?
推荐答案
在生成的复杂性 随机数为O(1)。你的意思是什么是它的运行时间和内存方面的成本?
The complexity of generating a random number is O(1). Do you mean "what are its costs in terms of runtime and memory"?
您可以用微基准,例如,测量它们JUnit的基准测试或布伦特博耶的基准(见这样的工具在什么是最好的宏观基准测试工具/框架来衡量一个一个LARG列表-threaded复杂的算法在Java中?)。
You can measure them with a micro-benchmark, e.g. junit-benchmark or Brent Boyer's Benchmark (see a larg list of such tools at What is the best macro-benchmarking tool / framework to measure a single-threaded complex algorithm in Java?).
此外,我认为Java类的随机数生成器是相当快的,但统计糟糕。而使用外部库,例如梅森倍捻机在 http://www.cs.gmu.edu/~sean/research/ ,或者,如果运行时是如此重要的是你,快速Mersenne扭曲。
Furthermore, I think Javas random number generators are quite fast, but statistically bad. Rather use external libraries, e.g. the Mersenne Twister at http://www.cs.gmu.edu/~sean/research/, or, if runtime is so important for you, the Fast Mersenne Twister.
相关推荐
最新文章