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

后端 未结 26 3273
自闭症患者
自闭症患者 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:18

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

    0 讨论(0)
  • 2020-12-15 06:20

    "Kids, unless they're broken, computers never lie, and they always do what you tell them to do. Even when we are disappointed by the results, it always turns out that they were doing what they were told to do with complete fidelity. They can only do two things: add one and one, and move a number from one place to another. If you want them to produce random numbers, you need to explain to them how to do that in terms of adding one and one and moving. Once you have explained that, the results will not be random."

    0 讨论(0)
  • 2020-12-15 06:21

    How about, "Because computers just follow instructions, and random numbers are the opposite of following instructions. If you make a random number by following instructions, then it's not very random! Imagine trying to give someone instructions on how to choose a random number."

    0 讨论(0)
  • 2020-12-15 06:21

    Because given any input, an algorithm produces the exact same output every single time. And you can't just provide a "random" input, because you're trying to generate the random number in the first place.

    0 讨论(0)
  • 2020-12-15 06:21

    It is hard because given the same sets of inputs and conditions, a program will produce the same result everytime. This by definition is not random.

    0 讨论(0)
  • 2020-12-15 06:21

    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).

    0 讨论(0)
提交回复
热议问题