简体   繁体   English

有没有办法在 Numpy 中实现更新的伪随机数生成器

[英]Is there a way to implement a newer pseudo random number generator in Numpy

I would like to try different pseudo-random number generators (PRNG) in Numpy.我想在 Numpy 中尝试不同的伪随机数生成器 (PRNG)。 It is mostly an academic curiosity to see how different algorithms compare.了解不同算法的比较主要是一种学术好奇心。 Does Numpy has a straightforward way of pointing to a different PRNG, or would I need to alter the source code? Numpy 是否有一种直接指向不同 PRNG 的方法,还是我需要更改源代码?

Changing the random number generation is not a provided method / thing you can do with python, you can change the seed for the generation however, but this will do little for the actual generation of random numbers, Python uses the Mersenne Twister algortihm to generate its random numbers, if you want to change the algorithm you will need to change the source code for it.更改随机数生成不是提供的方法/您可以使用 python 执行的操作,但是您可以更改生成的种子,但这对于随机数的实际生成几乎没有作用,Python 使用 Mersenne Twister 算法生成其随机数,如果要更改算法,则需要更改其源代码。 I don't know where it is, but I did do some research into this stuff a while back.我不知道它在哪里,但不久前我确实对这些东西进行了一些研究。 Heres a wiki link for all the random numnber generation algorithms, I dont recommend coding any of them as they are ment to be complex, hinting towards the idea of randomness.这是所有随机数生成算法的 wiki 链接,我不建议对它们中的任何一个进行编码,因为它们很复杂,暗示了随机性的概念。 link:关联:

https://en.wikipedia.org/wiki/List_of_random_number_generators https://en.wikipedia.org/wiki/List_of_random_number_generators

In addition, python does offer some variety in the forms of generation, however the random method is pretty stedfast for whatever you may want to use it for, if you want a faster method you can go with a TinyMT but you will again need to code it by hand.此外,python 确实在 forms 一代中提供了一些变化,但是随机方法对于您可能想要使用的任何内容都非常稳定,如果您想要更快的方法,您可以 Z34D1F91FB2E514B8576FAB1A75A89A6 使用 TinyMT 进行编码用手。 Below is a link to all of the random methods, including the seed:下面是所有随机方法的链接,包括种子:

https://docs.python.org/3/library/random.html https://docs.python.org/3/library/random.html

Hope this helped, and I would advise against trying to change the source code for random number generation, as randomness only really becomes a factor in security and otherwise a basic system like MT will do fine.希望这会有所帮助,我建议不要尝试更改随机数生成的源代码,因为随机性只会真正成为安全性的一个因素,否则像 MT 这样的基本系统就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM