
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@hyperfrontend/random-generator-utils
Advanced tools
Statistical random distributions and UUID generation for simulations, testing, and procedural content.
Statistical random distributions and UUID generation for simulations, testing, and procedural content.
@hyperfrontend/random-generator-utils provides random number generators beyond JavaScript's basic Math.random(), focusing on statistical distributions used in simulations, load testing, and procedural generation. It includes Gaussian (normal), exponential, power law, and logarithmic distributions, plus UUID v4 generation and seeded pseudo-random functions.
Unlike cryptographic random generators (like Web Crypto API), these utilities prioritize reproducibility and distribution shapes over security. The seeded pseudo-random generator allows deterministic sequences for testing, while statistical distributions model real-world phenomena like response times, user behavior, and natural variation.
uuidV4(), isUuidV4())All generators use Math.random() as the entropy source, transformed mathematically to match target distributions. Gaussian uses Box-Muller transform, exponential uses inverse transform sampling. Seeded generator uses sine function for deterministic output.
Math.random() generates uniform distributions, but real-world events follow different patterns. User response times cluster around an average (Gaussian), server failures often show exponential decay, and popularity follows power law distributions (80/20 rule). These generators let you model realistic scenarios in load tests and simulations.
The seeded pseudo-random generator (randomPseudo()) produces deterministic output from a numeric seed. This enables reproducible test scenarios, snapshot testing with "random" data, and debugging flaky tests caused by true randomness. Time-based seeding (randomPseudoTimeBased()) provides daily or hourly variations while maintaining reproducibility within those windows.
Many projects pull in the uuid package (500KB+) just for v4 UUIDs. This library provides a lightweight alternative with both generation and validation. Ideal for test fixtures, trace IDs, or non-security-critical unique identifiers without bloating bundles.
All generators are pure functions accepting parameters and returning numbers. This makes them composable in data generation pipelines, Array methods (Array.from({ length: 100 }, () => randomGaussian(0, 100))), or streaming data generators for charts and visualizations.
npm install @hyperfrontend/random-generator-utils
import {
randomGaussian,
randomExponential,
randomPowerLaw,
randomUniform,
randomPseudo,
uuidV4,
isUuidV4,
} from '@hyperfrontend/random-generator-utils'
// Gaussian (normal) distribution - ideal for modeling natural variation
const responseTime = randomGaussian(100, 300) // ms, centered around 200ms
const userHeight = randomGaussian(160, 180) // cm, most values near 170cm
// Exponential distribution - models time between independent events
const timeBetweenRequests = randomExponential(0.5) // λ=0.5, mean=2 seconds
const failureRate = randomExponential(0.1) // λ=0.1, mean=10 units
// Power law distribution - models "rich get richer" phenomena
const popularity = randomPowerLaw(2, 1, 1000) // Few items very popular
const citySize = randomPowerLaw(2.5, 100, 1000000) // Zipf's law for cities
// Uniform distribution - flat probability across range
const randomDelay = randomUniform(0, 1000) // Any value 0-1000ms equally likely
// Seeded pseudo-random for reproducible tests
const seed = 42
const value1 = randomPseudo(seed) // Always same output for seed=42
const value2 = randomPseudo(seed) // Identical to value1
// UUID generation
const id = uuidV4() // "a3bb189e-8bf9-4558-9e3e-e7b9a9e7b8c1"
console.log(isUuidV4(id)) // true
console.log(isUuidV4('not-a-uuid')) // false
randomUniform(min, max) - Uniform distribution (flat probability)randomGaussian(min, max) - Gaussian/normal distribution (bell curve)randomExponential(lambda) - Exponential distribution (decay)randomPowerLaw(alpha, min, max) - Power law distribution (long tail)randomLogarithmic(scale) - Logarithmic distributionrandomPseudo(seed) - Seeded pseudo-random (reproducible)randomPseudoTimeBased(seedTime) - Time-based seeding for date/time variationsuuidV4() - Generate RFC 4122 version 4 UUIDisUuidV4(str) - Validate UUID v4 format// Model realistic user behavior with varying response times
const users = Array.from({ length: 1000 }, () => ({
thinkTime: randomExponential(0.5), // Time between actions
responseTime: randomGaussian(50, 200), // Server response latency
requestCount: Math.floor(randomPowerLaw(2, 1, 100)), // Request frequency
}))
// Generate reproducible test datasets
const seed = Date.now()
const testData = Array.from({ length: 50 }, (_, i) => ({
id: uuidV4(),
score: randomPseudo(seed + i) * 100, // Reproducible but varied
timestamp: new Date(Date.now() + randomUniform(0, 86400000)),
}))
// Generate varied but natural-looking values
const terrain = {
height: randomGaussian(0, 100), // Centered around 50
vegetation: randomUniform(0, 1), // Uniform coverage
populationDensity: randomPowerLaw(2, 1, 1000), // Power law distribution
}
| Platform | Support |
|---|---|
| Browser | ✅ |
| Node.js | ✅ |
| Web Workers | ✅ |
| Deno, Bun, Cloudflare Workers | ✅ |
| Format | File | Tree-Shakeable |
|---|---|---|
| ESM | index.esm.js | ✅ |
| CJS | index.cjs.js | ❌ |
| IIFE | bundle/index.iife.min.js | ❌ |
| UMD | bundle/index.umd.min.js | ❌ |
Bundle size: 1 KB (minified, self-contained)
<!-- unpkg -->
<script src="https://unpkg.com/@hyperfrontend/random-generator-utils"></script>
<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/@hyperfrontend/random-generator-utils"></script>
<script>
const { randomGaussian, randomUniform, uuid4 } = HyperfrontendRandomGenerator
</script>
Global variable: HyperfrontendRandomGenerator
This library is part of the hyperfrontend monorepo.
MIT
FAQs
Statistical random distributions and UUID generation for simulations, testing, and procedural content.
The npm package @hyperfrontend/random-generator-utils receives a total of 152 weekly downloads. As such, @hyperfrontend/random-generator-utils popularity was classified as not popular.
We found that @hyperfrontend/random-generator-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.