为什么在util类中有48位种子? [英] why 48 bit seed in util Random class?

查看:161
本文介绍了为什么在util类中有48位种子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这个类在其线性同余公式中使用48位种子?
我本来期望32或64 ...

Why this class uses 48 bit seed in its linear congruence formula? I would have expected 32 or 64...

我知道当要求32位值时需要更高位的位。但为什么只有16个额外的位?这是一个随机选择吗?

I know it takes higher order bits when asked for 32 bit values. But why only 16 more additional bits? Was it a "random" choice?

推荐答案

由于LCG的性质,您需要更多的状态位而不是输出位。这样状态的低阶位根本不是非常随机的。因此,如果您需要32位输出,则需要超过32位的状态。

You need more bits of state than bits of output, because the nature of an LCG is such that the low-order bits of state are not very random at all. So if you want 32-bit outputs, you need more than 32 bits of state.

为什么使用48而不是64?因为48就足够了,并且你正在设计这个几十年前,所以有充分的理由想要避免使用比严格必要的资源更多的资源。

Why use 48 rather than 64? Because 48 is enough, and you're designing this decades ago, so there are good reasons to want to avoid using any more resources than are strictly necessary.

这篇关于为什么在util类中有48位种子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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