Skip to content

Chaotic random number generator with PCG64, MT19937, and statistical distributions

License

Notifications You must be signed in to change notification settings

cloudglides/nox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 15, 2026
f93ff27 · · Jan 15, 2026

History

54 Commits
Dec 26, 2025
Dec 25, 2025
Dec 31, 2025
Dec 31, 2025
Dec 29, 2025
Dec 23, 2025
Dec 25, 2025
Jan 15, 2026
Dec 26, 2025
Dec 31, 2025
Dec 31, 2025

Repository files navigation

logo

Nox

InstallQuick startAPI reference

NPMGitHub

Simple, unpredictable random number generator.

Install

npm install @cloudglides/nox

Quick Start

import { rng, deterministic } from '@cloudglides/nox';


const r = rng();


r.nextFloat();      // 0.742...

r.nextInt(100);     // 47

r.int(1, 100);      // 73

r.bool(0.3);        // true/false (30% chance)

r.range(10, 20, 2); // Pick from range: 10, 12, 14, 16, 18, 20

r.choice([1, 2, 3]); // Pick one element


// Batch operations

r.floats(5);        // [0.123, 0.456, ...]

r.ints(5, 100);     // [47, 82, 23, ...]

r.bools(5);         // [true, false, true, ...]

Reproducible

import { deterministic } from '@cloudglides/nox';


const r = deterministic(42);

// Always same sequence

Distributions

import { rng, normal, exponential, uniform, poisson } from '@cloudglides/nox';


const r = rng();


normal(r, mean=0, stddev=1);

exponential(r, lambda=1);

uniform(r, min=0, max=1);

poisson(r, lambda=5);

Sampling

import { rng, shuffle, pick, sample } from '@cloudglides/nox';


const r = rng();


shuffle([1, 2, 3], r);

pick(['a', 'b', 'c'], r);

sample([1, 2, 3, 4, 5], 3, r);

State

import { rng, saveState, restoreState } from '@cloudglides/nox';


const r = rng();

const snapshot = saveState(r);


r.nextFloat();

restoreState(r, snapshot);

r.nextFloat(); // Same value

Weighted Sampling

import { rng, weightedPick, reservoirSample } from '@cloudglides/nox';


const r = rng();

const items = ['A', 'B', 'C'];

const weights = [0.5, 0.3, 0.2];


weightedPick(items, weights, r);        // Pick with probabilities

reservoirSample(stream, k, r);          // Sample k from large stream

Statistical Tests

import { rng, meanTest, varianceTest, kolmogorovSmirnovTest } from '@cloudglides/nox';


const r = rng();

const data = r.floats(1000);


const mean = meanTest(data);            // Test mean ≈ 0.5

const variance = varianceTest(data);    // Test variance ≈ 1/12

const ks = kolmogorovSmirnovTest(data); // Test uniform distribution

Generators

For reproducible results or specific generator properties:

import { RNG, PCG64, MT19937, Xorshift64, Splitmix64 } from '@cloudglides/nox';


const r = new RNG(PCG64, seed);      // PCG64 (default, fast, high quality)

const r = new RNG(MT19937, seed);    // MT19937 (Mersenne Twister)

const r = new RNG(Xorshift64, seed); // Xorshift64 (simple, fast)

const r = new RNG(Splitmix64, seed); // Splitmix64 (statistical mixing)

License

ISC

About

Chaotic random number generator with PCG64, MT19937, and statistical distributions

Resources

License

Stars

Watchers

Forks