Giter Site home page Giter Site logo

sindresorhus / park-miller Goto Github PK

View Code? Open in Web Editor NEW
54.0 5.0 3.0 7 KB

Park-Miller pseudorandom number generator (PRNG)

License: MIT License

JavaScript 90.26% TypeScript 9.74%
park-miller prng pseudorandom pseudorandom-number-generator random nodejs npm-package

park-miller's Introduction

park-miller

Park-Miller pseudorandom number generator (PRNG)

Install

$ npm install park-miller

Usage

import ParkMiller from 'park-miller';

const random = new ParkMiller(10);

random.integer();
//=> 2027521326

API

const random = new ParkMiller(seed)

seed

Type: integer

Initialization seed.

random.integer()

random.integerInRange(min, max)

random.float()

random.floatInRange(min, max)

random.boolean()

Related

  • randoma - User-friendly pseudorandom number generator (PRNG)

park-miller's People

Contributors

bendingbender avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

park-miller's Issues

some problems regarding this implementation

I noticed that in file "index.js" line 14, you add the seed by (MAX_INT32 - 1) which is 2147483646 when seed <= 0, but the implementation on wikipedia and the book around my hand "Data structures and algorithm analysis in c++" all add the seed by 2147483647 when seed < 0.
And I also noticed that in file "index.js" line 25 you use Math.round to get integer from the float value. but if you implemented it in this way, your "integerInRange" will not get a uniform distribution in [min, max], min and max value is roughly half the possibility of other numbers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.