Math.random使用什么算法? [英] What algorithm does Math.random use?

查看:128
本文介绍了Math.random使用什么算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我一直在学习计算机科学,每当随机数字出现时,它总是Mersenne Twister。甚至从来没有一个问题,没有其他选择。只是,使用Mersenne Twister。

Since I've been studying Computer Science, whenever random numbers come up, it's always Mersenne Twister. There's never even a question, no alternative. Just, use Mersenne Twister.

那么JavaScript的Math.random使用什么?似乎它应该使用Mersenne Twister,因为它显然没有同行,但我找不到它是否有任何参考。

So what does JavaScript's Math.random use? It seems like it ought to use Mersenne Twister, since it's apparently without peer, but I can't find any reference to whether it does or not.

有谁知道什么它依赖于,和/或为什么它不是MT,如果是这样的话?

Does anyone know what it relies on, and/or why it isn't MT, if that's the case?

推荐答案

它可能是特定于实现的。 ECMAScript规范不强制任何算法,因此Linux JavaScript实现可能会很好地使用 / dev / urandom

It's likely implementation specific. The ECMAScript specification does not force any algorithm, so a Linux JavaScript implementation might very well use /dev/urandom.

这篇关于Math.random使用什么算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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