blum-blum-shub
Random number generator based on a formula using prime numbers.
Last updated 2 months ago by fellgill .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install blum-blum-shub 
SYNC missed versions from official npm registry.

View on NPM View on Github View on Github

Blum Blum shub algorithm

Random number generator based on a formula using prime numbers.

How to use ?

Started by installing the package

  • In npm : npm install blum-blum-shub or npm install github:algorithmsjs/blum-blum-shub

  • In yarn : yarn add blum-blum-shub or yarn add github:algorithmsjs/blum-blum-shub

  • In pnpm : pnpm add blum-blum-shub or pnpm add github:algorithmsjs/blum-blum-shub

Documentation

Formula: Formula

Params

Name Type
p Number
q Number
seed Number
  • On JavaScript :
// Example
const bbs = require('blum-blum-shub');
const BBS = new bbs(9, 15, 7);

let i = 0;

while(i < 6) {
	// Get the next random number
	console.log(BBS.randomNumber());
	
	// Get the next random bit
	console.log(BBS.randomBit());
	
	i++;
}
  • On CoffeeScript :
# Example
bbs = require('blum-blum-shub')
BBS = new bbs(9, 15, 7)

 i = 0

while i < 6
	# Get the next random number
	console.log BBS.randomNumber()
	
	# Get the next random bit
	console.log BBS.randomBit()
	
	i++

...

Benchmark

  • randomNumber x 10,425,712 ops/sec ±0.86% (89 runs sampled)
  • randomBit x 10,280,317 ops/sec ±0.92% (90 runs sampled)
  • Fastest is randomNumber

Fact

Blum Blum Shub (BBS) is an algorithm capable of producing pseudo-random numbers. It was proposed in 1986 by Lenore Blum, Manuel Blum and Michael Shub1, hence its name.

Copyright 2020 FellGill

Current Tags

  • 0.0.3                                ...           latest (2 months ago)

3 Versions

  • 0.0.3                                ...           2 months ago
  • 0.0.2                                ...           2 months ago
  • 0.0.1                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |