用任何编程语言生成真随机数生成器 [英] Generate True Random Number Generator in any of programming language

查看:99
本文介绍了用任何编程语言生成真随机数生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档,java.util.Random 不是真正的随机生成器.

As per documentation, java.util.Random is not a true random generator.

来自以下链接:http://docs.oracle.com/javase/7/docs/api/java/util/Random.html,已经引用了

From below link: http://docs.oracle.com/javase/7/docs/api/java/util/Random.html, it has been quoted that

此类的一个实例用于生成伪随机数流.该类使用 48 位种子,使用线性同余公式对其进行修改.

An instance of this class is used to generate a stream of pseudorandom numbers. The class uses a 48-bit seed, which is modified using a linear congruential formula.

我必须实现真随机数生成器.请建议使用任何编程语言或 java 的替代方案

I have to implement True Random Number Generator. Please suggest alternatives in any programming language Or in java

推荐答案

您正在尝试仅使用 确定性算法 生成随机数,该算法在某些编程语言(如 java)中表示.不可能在确定性设备中创建真正的随机数生成器.

You are trying to generate a random number using only a deterministic alghorithm, expresed in some programming language like java. It is not possible to create a true random number generator in a deterministic device.

根据确定性的定义,我们知道如果设备配置为相同的状态,它将始终表现出相同的行为.

By the very definition of deterministic we know that if a device is configured in the same state it will always exhibit the same behaviour.

在真随机发生器的特殊情况下,设备将是一种没有输入和一个输出(所需的随机数)的算法.在这种情况下,确定性算法只能产生始终相同的数字.因此不是随机的.

In the particular case of a true random generator the device would be an algorithm with no input and one output (the dessired random number). Under such conditions a deterministic algorithm can only produce always the same number. Thus not random.

伪随机生成器通过存储内部状态来模拟随机性,它们用于生成具有随机外观的数​​字序列.从概念上讲,内部状态只是算法的另一个输入,对于相同的内部状态,算法将始终产生相同的输出.尽管这些算法提供了不断变化的数字流,但它们并不是真正随机的,因为它们总是会产生相同的数字串.

Pseudorandom generators imitate randomness by storing an internal state they use to produce a sequence of numbers with an appearance of randomness. Conceptually that internal state is just another input of the algorithm and for the same internal state the algorithm will always produce the same output. Though these algorithms provide a stream of changing numbers they are not at all truly random because they will always produce the same string of numbers.

您可以尝试通过每次使用不同的值初始化此类伪随机算法的内部状态来尝试进一步改进,从而获得不同的随机数流.但这带来了两个问题:

You can try to improve a bit more by initializing the internal state of such pseudorandom algorithm with a different value each time, thus getting different stream of random numbers. But this poses two problems :

  • 您从哪里获得初始状态?如果您始终使用相同的初始状态,则不会得到不同的数字流.尝试通过算法(因此确定性地)获得随机状态又是同样的问题.
  • 即使您从物理源获得真正随机的初始状态,数字流仍不会是真正随机的.每个数字都是由前一个状态的确定性算法计算出来的.因此,通过检查一长串数字,最终可以知道下一个数字是什么.

实际上可以使用算法创建随机数生成器.您将不得不使用非确定性算法.但是这样的算法本身需要一个随机数生成器,以便具有不确定性.例如物理设备或竞争条件.

It is actually possible to create a random number generator using an algorithm. You would have to use a nondeterministic algorithm. But such algorithms require a random number generator themselves in order to be nondeterministic. Such as physical devices or race conditions.

这篇关于用任何编程语言生成真随机数生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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