没有生成随机函数完全随机的号码? [英] Generating totally random numbers without random function?

查看:96
本文介绍了没有生成随机函数完全随机的号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  真随机数发生器

我的朋友交谈的一天,我们试图找出是否有可能没有一个随机函数的帮助下,生成完全随机的号码?在C语言中,例如兰特产生伪随机数。或者,我们可以使用类似函数srand(时间(NULL));这将允许计算机读取它的时钟数字作为种子值。所以,如果我明白了一切我迄今看错的话,我pretty确保没有随机函数实际上产生忠实地随机数。如何将一个写生成是完全随机的,会有什么code看起来像数的程序?

I was talking to a friend the other day and we were trying to figure out if it is possible to generate completely random numbers without the help of a random function? In C for example "rand" generates pseudo-random numbers. Or we can use something like "srand( time( NULL ) );" This will allow the computer to read numbers from its clock as seed values. So if I understand everything I have read so far right, then I am pretty sure that no random function actually produces truely random numbers. How would one write a program that generates numbers that are completely random and what would code look like?

推荐答案

这看起来像:

int random = CallHardwareRandomGenerator();

即使有硬件,随机性是棘手的。有东西是物理随机(原子衰变是随机的,但随着predictable平均量,从而可以用来作为随机信息的来源),有事情是物理上足够随机,使prediction不切实际(这是赌场怎么赚钱)。

Even with hardware, randomness is tricky. There are things which are physically random (atomic decay is random, but with predictable average amounts, so that can be used as a source of random information) there are things that are physically random enough to make prediction impractical (this is how casinos make money).

有东西,在很大程度上是不确定的(混合来自关键中风发生率,鼠标移动,和这样的一些东西的信息),这是随机性的许多用途的足够好的来源。

There are things that are largely indeterminate (mix up information from key-stroke rate, mouse-movements, and a few things like that), which are a good-enough source of "randomness" for many uses.

在数学上,我们不能生产的随机性,但我们可以提高配送做出predict更难的事。密码学的PRNG做这个比大多数较强的工作,但在资源方面都比较昂贵。

Mathematically, we cannot produce randomness, but we can improve distribution and make something harder to predict. Cryptographic PRNGs do a stronger job at this than most, but are more expensive in terms of resources.

这篇关于没有生成随机函数完全随机的号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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