admin管理员组

文章数量:1431955

Since I've been studying Computer Science, whenever random numbers e up, it's always Mersenne Twister. There's never even a question, no alternative. Just, use 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.

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

Since I've been studying Computer Science, whenever random numbers e up, it's always Mersenne Twister. There's never even a question, no alternative. Just, use 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.

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

Share Improve this question asked Apr 28, 2012 at 7:17 temporary_user_nametemporary_user_name 37.2k48 gold badges161 silver badges243 bronze badges 1
  • Quantum puting offers algorithms that can generate more "natural" random numbers. [Theoretically] – KBN Commented Apr 28, 2012 at 7:24
Add a ment  | 

1 Answer 1

Reset to default 7

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

本文标签: javascriptWhat algorithm does Mathrandom useStack Overflow