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条回答
可以哭但决不认输i
2楼-- · 2019-01-23 03:40

Because computers are deterministic machines.

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

Computers can only execute algorithmic computations, and a truly random number isn't an algorithmic thing. You can get algorithms that produce numbers that behave like random numbers; such algorithms are called 'Pseudo-Random number generators'.

At various times in the past, people have made random number generators from analog-digital converters connected to sources of electronic noise, but this tends to be fairly specialised kit.

查看更多
【Aperson】
4楼-- · 2019-01-23 03:42

Computers just don't have suitable hardware. Ordinary computer's hardware is meant to be deterministic. With suitable hardware like mentioned here random numbers are not a problem at all.

查看更多
再贱就再见
5楼-- · 2019-01-23 03:46

As surprising as it may seem, it is difficult to get a computer to do something by chance. A computer follows its instructions blindly and is therefore completely predictable. (A computer that doesn't follow its instructions in this manner is broken.) There are two main approaches to generating random numbers using a computer: Pseudo-Random Number Generators (PRNGs) and True Random Number Generators (TRNGs).

查看更多
时光不老,我们不散
6楼-- · 2019-01-23 03:47

Generating random numbers on a computer is like playing "Eenie meenie miney moe" when choosing who's It first in a game of tag. On the surface it does look random, but when you get into the details, it's completely deterministic. It's hard to make eenie meenie miney moe into a scheme that a person really can't predict the outcome of.

Also there's some difficulties with getting the distribution nice and even.

查看更多
7楼-- · 2019-01-23 03:47

Its not hard, here's a couple for free: 12, 1400, 397.6

查看更多
登录 后发表回答