https://github.com/mawi12345/pcg32
A simple fast space-efficient statistically good algorithm for random number generation in JavaScript
https://github.com/mawi12345/pcg32
algorithm javascript random rng
Last synced: 4 days ago
JSON representation
A simple fast space-efficient statistically good algorithm for random number generation in JavaScript
- Host: GitHub
- URL: https://github.com/mawi12345/pcg32
- Owner: mawi12345
- License: apache-2.0
- Created: 2017-06-18T18:45:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T08:32:57.000Z (about 1 year ago)
- Last Synced: 2025-09-27T06:22:42.086Z (4 months ago)
- Topics: algorithm, javascript, random, rng
- Language: JavaScript
- Homepage: https://mawi12345.github.io/pcg32/
- Size: 981 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pcg32.js
[](https://github.com/mawi12345/pcg32/issues) [](https://www.npmjs.com/package/pcg32)
A simple fast space-efficient statistically good algorithm for random number generation in JavaScript.
## Installation
```bash
npm install pcg32
```
or
```bash
yarn add pcg32
```
## Usage
```javascript
var PCG32 = require('pcg32')
var seed = 42;
var stream = 54;
var pcg32 = new PCG32(seed, stream);
// Print a radnom number between 0 and 4294967295
console.log(pcg32.random());
// Print a radnom number between 0 and 5
console.log(pcg32.random(6));
// Print 0 or 1
console.log(pcg32.random(2));
```