rand48

Provides a seedable uniformly distributed random number generator for node.js, based on POSIX nrand48_r function

npm install rand48
1 downloads in the last week
25 downloads in the last month

Description

Provides a seedable uniformly distributed random number generator for node.js by binding to the POSIX nrand48_r function.

NOTE: Only tested under Linux

Installation with NPM

npm install rand48

Usage

var Rand48 = require("rand48").Rand48;

var r = new Rand48();    // Creates a new Rand48 object, with no seed
r.rand(1, 10);            // Requests a number between 1 and 10 inclusive

var r2 = new Rand48(43912);        // Creates a new Rand48 object with a seed of 43912
r2.rand(1, 10);                    // Produces the number 10, random based on seed

Note that the constructor to Rand48 takes up to 3 unsigned shorts (0 to 65,535) as a single seed

Manual Installation

git clone "https://github.com/Sembiance/node-rand48.git"
cd node-rand48
node-waf configure build
# Now can in JavaScript: require("./build/default/rand48") 
npm loves you