What is meant by a seed in random number generation?

夙愿已清 提交于 2019-12-02 08:20:30

It's an initial value for a random number generator to base its sequence of random numbers on. If you seed two random number generators with the same value, they'll produce the same sequence of numbers. This is useful for testing purposes. In production, you typically seed a random number generator with a value that's hard to guess, like the millisecond value from your system clock.

A seed is used to initialize a pseudorandom number generator. It is a starting point for all random numbers to be generated. If you initialize a PRNG with the same seed, for example a number 100, you will always get the same numbers generated and the results will be deterministic (that can be useful for testing). If you initialize the PRNG with a variable value, for example a timestamp, you should get different results with high probability (used in production). Refer to:

http://en.wikipedia.org/wiki/Pseudorandom_number_generator

http://en.wikipedia.org/wiki/Random_seed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!