与随机数生成算法有关的种子是什么?为什么要花更多的计算机时间来创建此种子? [英] What is a seed in relation to a random number generation algorithm and why is computer time used to create this seed more often than not?

查看:126
本文介绍了与随机数生成算法有关的种子是什么?为什么要花更多的计算机时间来创建此种子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到种子用于初始化随机数生成器.但是似乎种子的随机性对于从生成器中获得良好的随机性并不重要.所以我想了解什么是种子?为什么这样称呼呢?最后,为什么在计算机系统中使用 time 生成此类种子?

I read that seeds are used to initialize random number generators. But seems like the randomness of the seed doesn't matter much for getting good randomness from the generator. So I want to understand what is a seed actually? Why is it called so? And lastly why time in a computer system is used to generate such seeds?

推荐答案

伪随机数生成器生成数字序列.它并不是真正随机的,但通常是数学计算,可以产生与某些所需分布相匹配的输出,并且没有明显的模式.为了产生这样的序列,必须存储 state ,以便生成器能够生成该序列中的下一个数字.每次使用上一步输出的一部分来更新状态.

A pseudo-random number generator produces a sequence of numbers. It isn't truly random, but generally a mathematical calculation which produces an output that matches some desirable distribution, and without obvious patterns. In order to produce such a sequence, there must be state stored for the generator to be able to generate the next number in that sequence. The state is updated each time using some part of the output from the previous step.

播种显式初始化此状态. 种子"是一个起点,可以从中成长.在这种情况下,是一个数字序列.

Seeding explicitly initialises this state. A 'seed' is a starting point, from which something grows. In this case, a sequence of numbers.

这可以用于始终生成相同的序列(通过使用已知的常量种子),这对于确定性行为很有用.这对于调试,某些网络应用程序,密码学等非常有用.

This can be used either to always generate the same sequence (by using a known constant seed), which is useful for having deterministic behaviour. This is good for debugging, for some network applications, cryptography, etc.

或者,在您希望行为不可预测的情况下(每次运行程序,打牌游戏时总是不同),您可以为种子添加可能不断变化的数字,例如时间.

Or, in situations where you want the behaviour to be unpredictable (always different each time you run a program, a card game perhaps), you can seed with a number likely to be continually changing, such as time.

序列的随机性"不依赖于选择的种子,尽管它不依赖于重新播种.

The 'randomness' of the sequence does not depend on the seed chosen, though it does depend on not reseeding the sequence.

这篇关于与随机数生成算法有关的种子是什么?为什么要花更多的计算机时间来创建此种子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆