我应该如何在Python中使用random.jumpahead [英] How should I use random.jumpahead in Python

查看:168
本文介绍了我应该如何在Python中使用random.jumpahead的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序可以执行特定的实验1000次(多线程,因此可以同时进行多个实验).每个实验都需要评估. 50.000 random.random()调用.

I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls.

获得这种随机性的最佳方法是什么?我可以将随机对象复制到每个实验中,并且比50.000 * expid的超前行为更有效.该文档表明jumpahead(1)已经在扰乱状态,但这是真的吗?

What is the best approach to get this really random. I could copy a random object to every experiment and do than a jumpahead of 50.000 * expid. The documentation suggests that jumpahead(1) already scrambles the state, but is that really true?

或者还有另一种方式可以以最佳方式"做到这一点?

Or is there another way to do this in 'the best way'?

(不,随机数不用于安全性,而是用于都市化的急速算法.唯一的要求是实验是独立的,而不是随机序列是否可以某种方式预测)

(No, the random numbers are not used for security, but for a metropolis hasting algorithm. The only requirement is that the experiments are independent, not whether the random sequence is somehow predictable or so)

推荐答案

您不应使用该功能.没有证据表明它可以在Mersenne Twister发生器上运行.实际上,正是出于这个原因,它已从Python 3中删除了.

You shouldn't use that function. There is no proof it can work on Mersenne Twister generator. Indeed, it was removed from Python 3 for that reason.

有关在并行环境中生成伪随机数的更多信息,请参见David Hill的这篇文章.

For more information about generation of pseudo-random numbers on parallel environments, see this article from David Hill.

这篇关于我应该如何在Python中使用random.jumpahead的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆