npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mersennetwister

v0.2.3

Published

A standalone, pure JavaScript implementation of the Mersenne Twister pseudo random number generator. Compatible with Node.js, requirejs and browser environments.

Downloads

15,923

Readme

mersennetwister

The Mersenne Twister is a pseudo-random number generator invented by Makoto Matsumoto in 1997. Details can be found on the Wikipedia page and on Matsumoto's website.

This implementation is based on Sean McCullough's port of the original C code written by Makato Matsumoto and Takuji Nishimura.

Improvements over Sean's version are

Please note that the mersenne twister is not cryptographically secure.

Installation and setup

Node.js

Simply run npm install mersennetwister (or npm install --save mersennetwister of you want to directly add it to your package.json file). Import as usual: var MersenneTwister = require('mersennetwister');

Jam

Use the Jam command line tool: jam install mersennetwister and import as usual require(['mersennetwister'], function (MersenneTwister) { ...

Bower

Via the Bower tool: bower install mersennetwister

requirejs

Tools like Jam will usually configure requirejs so that it can be accessed via its package name (i.e., mersennetwister). If you use requirejs without such a customized configuration you need to import it via its camelcased filename: requirejs(['MersenneTwister'], function (MersenneTwister) { ...

Standalone

Download and include the src/MersenneTwister.js file: <script src="path/to/MersenneTwister.js"></script>. It is now available as the global variable MersenneTwister.

Usage

You can either just use the static random method of the module, which will return a random float just like Math.random does. If desired you can also instantiate your own instance of the mersenne twister and use its methods:

var mt = new MersenneTwister(seed); // if no seed is defined, seed randomly

mt.int();    // random 32-bit integer
mt.int31();  // random 31-bit integer

mt.rnd();       // random float in the interval [0;1[ with 32-bit resolution
mt.random();    // random float in the interval [0;1[ (same as mt.rnd() above)
mt.rndHiRes();  // random float in the interval [0;1[ with 53-bit resolution
mt.real();      // random float in the interval [0;1]
mt.realx();     // random float in the interval ]0;1[

mt.seed(seed);      // (re)seed the generator with an unsigned 32-bit integer
mt.seedArray(key);  // (re)seed using a state vector of unsigned 32-bit integers

Take a look at the inventor´s website if more detailed information is required.

Licensing

As indicated here, the Mersenne Twister algorithm is free to be used for any purpose, including commercial use. The license file of this module contains the BSD 3-clause license found in the C implementation on which it is based.

Changelog

0.2.3 (12/18/2015)
  • updated license used to BSD-3-Clause (@sibartlett)
0.2.2 (10/28/2015)
  • fixed typo readme
  • fixed license in package.json
  • bump some dependencies
0.2.1 (10/16/2014)
  • added bower.json (with ignore section) and .editorconfig
0.2.0 (07/13/2014)
  • added .random() alias to .rnd()
0.1.1 (06/19/2013)
  • published as a Jam module
  • registered as a Bower component
  • added installation instructions
  • completed jsdoc annotations and added build target
  • changelog added ;)
0.1.0 (06/16/2013)
  • initial release
  • published as an npm module