Why is it hard for a program to generate random numbers?

后端 未结 26 3571
自闭症患者
自闭症患者 2020-12-15 05:38

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

So I\'m hoping someone on SO can.

26条回答
  •  情书的邮戳
    2020-12-15 06:03

    It's easy to come up with an algorithm that generates unexpected numbers, that appear random in some sense. But to design an algorithm that generates true random numbers, well, that's hard.

    Imagine designing an algorithm to simulate a dice roll. You can easily formulate some procedure to generate different numbers on each iteration. But can you guarantee that, in the long run (I mean, up to the infinity), the amount of times that 6 came out will be the same as any other number? When designing a good random number generator, that's the kind of commitment that you have to assume. You have to provide strong guarantees (i.e. mathematical proofs) about the randomness, if the application (e.g. lottery) requires it.

提交回复
热议问题