Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

mtwist

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mtwist

Mersenne Twister random numbers

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

MTwist

  • A concise Mersenne Twister implementation in CoffeeScript/JavaScript
  • Includes the 2002 initialization improvements
  • Tested against the original C implementation

Why would I use this?

  • You want to be able to seed your random number generator to create reproducible sequences
  • You want to know exactly how your random numbers are generated across all JS engines

How do I use this?

x = Math.random();

becomes

seed = 1234567890;  // an integer between 0 and 4294967295
m = new MTwist(seed);
x = m.random();

Methods to produce evenly distributed integers in the ranges [0,n) and [m,n] are also provided.

For details, see index.coffee.

Licence

© Copyright 2014 – 2021 George MacKerron and released under the MIT Licence.

Keywords

random

FAQs

Package last updated on 10 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts