Gathering detailed insights and metrics for @stdlib/random-base-minstd-shuffle
Gathering detailed insights and metrics for @stdlib/random-base-minstd-shuffle
Gathering detailed insights and metrics for @stdlib/random-base-minstd-shuffle
Gathering detailed insights and metrics for @stdlib/random-base-minstd-shuffle
A linear congruential pseudorandom number generator (LCG) whose output is shuffled.
npm install @stdlib/random-base-minstd-shuffle
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (61.79%)
C (38.21%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
1 Stars
49 Commits
3 Watchers
5 Branches
14 Contributors
Updated on May 26, 2025
Latest Version
0.2.1
Package Id
@stdlib/random-base-minstd-shuffle@0.2.1
Unpacked Size
108.86 kB
Size
24.76 kB
File Count
17
NPM Version
8.19.4
Node Version
16.20.2
Published on
Feb 25, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
19
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
A linear congruential pseudorandom number generator (LCG) whose output is shuffled.
1npm install @stdlib/random-base-minstd-shuffle
1var minstd = require( '@stdlib/random-base-minstd-shuffle' );
Returns a pseudorandom integer on the interval [1, 2147483646]
.
1var v = minstd(); 2// returns <number>
Returns a pseudorandom number on the interval [0,1)
.
1var v = minstd.normalized(); 2// returns <number>
Returns a linear congruential pseudorandom number generator (LCG) whose output is shuffled.
1var rand = minstd.factory();
The function accepts the following options
:
Int32Array
containing pseudorandom number generator state. If provided, the function ignores the seed
option.boolean
indicating whether to copy a provided pseudorandom number generator state. Setting this option to false
allows sharing state between two or more pseudorandom number generators. Setting this option to true
ensures that a returned generator has exclusive control over its internal state. Default: true
.By default, a random integer is used to seed the returned generator. To seed the generator, provide either an integer
on the interval [1, 2147483646]
1var rand = minstd.factory({ 2 'seed': 1234 3}); 4 5var v = rand(); 6// returns 1421600654
or, for arbitrary length seeds, an array-like object
containing signed 32-bit integers
1var Int32Array = require( '@stdlib/array-int32' ); 2 3var rand = minstd.factory({ 4 'seed': new Int32Array( [ 1234 ] ) 5}); 6 7var r = rand(); 8// returns 20739838
To return a generator having a specific initial state, set the generator state
option.
1var rand; 2var bool; 3var r; 4var i; 5 6// Generate pseudorandom numbers, thus progressing the generator state: 7for ( i = 0; i < 1000; i++ ) { 8 r = minstd(); 9} 10 11// Create a new PRNG initialized to the current state of `minstd`: 12rand = minstd.factory({ 13 'state': minstd.state 14}); 15 16// Test that the generated pseudorandom numbers are the same: 17bool = ( rand() === minstd() ); 18// returns true
The generator name.
1var str = minstd.NAME; 2// returns 'minstd-shuffle'
Minimum possible value.
1var min = minstd.MIN; 2// returns 1
Maximum possible value.
1var max = minstd.MAX; 2// returns 2147483646
The value used to seed minstd()
.
1var rand; 2var v; 3var i; 4 5// Generate pseudorandom values... 6for ( i = 0; i < 100; i++ ) { 7 v = minstd(); 8} 9 10// Generate the same pseudorandom values... 11rand = minstd.factory({ 12 'seed': minstd.seed 13}); 14for ( i = 0; i < 100; i++ ) { 15 v = rand(); 16}
Length of generator seed.
1var len = minstd.seedLength; 2// returns <number>
Writable property for getting and setting the generator state.
1var r = minstd(); 2// returns <number> 3 4r = minstd(); 5// returns <number> 6 7// ... 8 9// Get a copy of the current state: 10var state = minstd.state; 11// returns <Int32Array> 12 13r = minstd(); 14// returns <number> 15 16r = minstd(); 17// returns <number> 18 19// Reset the state: 20minstd.state = state; 21 22// Replay the last two pseudorandom numbers: 23r = minstd(); 24// returns <number> 25 26r = minstd(); 27// returns <number> 28 29// ...
Length of generator state.
1var len = minstd.stateLength; 2// returns <number>
Size (in bytes) of generator state.
1var sz = minstd.byteLength; 2// returns <number>
Serializes the pseudorandom number generator as a JSON object.
1var o = minstd.toJSON(); 2// returns { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
2.1e9
(see Numerical Recipes in C, 2nd Edition, p. 279).1var minstd = require( '@stdlib/random-base-minstd-shuffle' ); 2 3var seed; 4var rand; 5var i; 6 7// Generate pseudorandom numbers... 8for ( i = 0; i < 100; i++ ) { 9 console.log( minstd() ); 10} 11 12// Create a new pseudorandom number generator... 13seed = 1234; 14rand = minstd.factory({ 15 'seed': seed 16}); 17for ( i = 0; i < 100; i++ ) { 18 console.log( rand() ); 19} 20 21// Create another pseudorandom number generator using a previous seed... 22rand = minstd.factory({ 23 'seed': minstd.seed 24}); 25for ( i = 0; i < 100; i++ ) { 26 console.log( rand() ); 27}
@stdlib/random-base/minstd
: A linear congruential pseudorandom number generator (LCG) based on Park and Miller.@stdlib/random-base/mt19937
: A 32-bit Mersenne Twister pseudorandom number generator.@stdlib/random-base/randi
: pseudorandom numbers having integer values.This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
project is not fuzzed
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More