Why is it hard for a program to generate random nu

2019-01-23 03:22发布

My kids asked me this question and I couldn't really give a concise, understandable explanation.

So I'm hoping someone on SO can.

标签: random
26条回答
一夜七次
2楼-- · 2019-01-23 03:24

Had to be done really

RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.

Source: http://xkcd.com/221/

查看更多
爷、活的狠高调
3楼-- · 2019-01-23 03:24

Its probably helpful to distinguish between a number that is hard to predict (which a computer can create) from something that is not deterministic (which is a bit tougher for computers, and theoretically, any physical being).

查看更多
姐就是有狂的资本
4楼-- · 2019-01-23 03:28

Because the only true source of randomness exists at the quantum level. With suitable hardware assists, computers can access this level. for example, they can sample the decay of a radioactve isotope or the noise from a thermionic valve. But your basic PC doesn't come with this cool stuff.

查看更多
萌系小妹纸
5楼-- · 2019-01-23 03:28

Because there is no such thing as a random number.

Random is a human concept that we use when we cannot comprehend data and do not understand it. If we are to believe that science will ultimately lead to an understanding of how everything works then surely everything is deterministic.

Take away the human and there is no random there is only "this". It happens because it happens, not because it is random.

查看更多
孤傲高冷的网名
6楼-- · 2019-01-23 03:28

It is relevant to note that humans perform very poorly at generating random numbers. Computers are worse because they just follow a strict set commands. Humans can only generate good (pseudo) random numbers when following an algorithm, a set of commands. Computers are the same.

Although it should be noted that computers can gather entropy from the "environment" connected to it, like keyboard and mouse actions, what aids in generating random numbers (either directly or by seeding a PRNG).

查看更多
够拽才男人
7楼-- · 2019-01-23 03:32

Primarily because computers don't have any functions that behave in discrete, non-random ways. A computer is predictable, which allows us to program reliable software. If it wasn't predictable it would be easier to generate a random number (since our software could rely on this unpredictable method).

While it's possible to generate pseudo-random numbers, and numbers that are distributed randomly, you cannot generate truly random numbers without separate hardware. There is hardware that generates truly random numbers based on "quantum" interactions (at least according to the manufacturers). Online poker sites sometimes use these adapters for their generators.

Apparently there are even online services to provide random numbers - random.org for example.

查看更多
登录 后发表回答