
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@stdlib/random-array-minstd-shuffle
Advanced tools
Create an array containing pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG) whose output is shuffled.
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!
Create an array containing pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG) whose output is shuffled.
npm install @stdlib/random-array-minstd-shuffle
var minstd = require( '@stdlib/random-array-minstd-shuffle' );
Returns an array containing pseudorandom integers on the interval [1, 2147483646].
var out = minstd( 10 );
// returns <Float64Array>
The function has the following parameters:
The function accepts the following options:
'float64'.By default, the function returns a Float64Array. To return an array having a different data type, set the dtype option.
var opts = {
'dtype': 'generic'
};
var out = minstd( 10, opts );
// returns [...]
Returns an array containing pseudorandom numbers on the interval [0, 1).
var out = minstd.normalized( 10 );
// returns <Float64Array>
The function has the following parameters:
The function accepts the following options:
'float64'.By default, the function returns a Float64Array. To return an array having a different data type, set the dtype option.
var opts = {
'dtype': 'generic'
};
var out = minstd.normalized( 10, opts );
// returns [...]
Returns a function for creating arrays containing pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG) whose output is shuffled.
var random = minstd.factory();
var out = random( 10 );
// returns <Float64Array>
var len = out.length;
// returns 10
out = random.normalized( 10 );
// returns <Float64Array>
len = out.length;
// returns 10
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.'float64'.'float64'.To seed the underlying pseudorandom number generator, set the seed option.
var opts = {
'seed': 12345
};
var random = minstd.factory( opts );
var out = random( 10, opts );
// returns <Float64Array>
The returned function accepts the following options:
The returned function has a normalized method which accepts the following options:
To override the default output array data type, set the dtype option.
var random = minstd.factory();
var out = random( 10 );
// returns <Float64Array>
var opts = {
'dtype': 'generic'
};
out = random( 10, opts );
// returns [...]
The underlying pseudorandom number generator.
var prng = minstd.PRNG;
// returns <Function>
The value used to seed the underlying pseudorandom number generator.
var seed = minstd.seed;
// returns <Int32Array>
Length of underlying pseudorandom number generator seed.
var len = minstd.seedLength;
// returns <number>
Writable property for getting and setting the underlying pseudorandom number generator state.
var state = minstd.state;
// returns <Int32Array>
Length of underlying pseudorandom number generator state.
var len = minstd.stateLength;
// returns <number>
Size (in bytes) of underlying pseudorandom number generator state.
var sz = minstd.byteLength;
// returns <number>
factory method does not update the existing shared state and, instead, points to the newly provided state array. In order to synchronize the output of the underlying generator according to the new shared state array, the state array for each relevant creation function and/or PRNG must be explicitly set.var logEach = require( '@stdlib/console-log-each' );
var minstd = require( '@stdlib/random-array-minstd-shuffle' );
// Create a function for generating random arrays originating from the same state:
var random = minstd.factory({
'state': minstd.state,
'copy': true
});
// Generate 3 arrays:
var x1 = random.normalized( 5 );
var x2 = random.normalized( 5 );
var x3 = random.normalized( 5 );
// Print the contents:
logEach( '%f, %f, %f', x1, x2, x3 );
// Create another function for generating random arrays with the original state:
random = minstd.factory({
'state': minstd.state,
'copy': true
});
// Generate a single array which replicates the above pseudorandom number generation sequence:
var x4 = random.normalized( 15 );
// Print the contents:
logEach( '%f', x4 );
@stdlib/random-array/minstd: create an array containing pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG).@stdlib/random-array/randu: create an array containing uniformly distributed pseudorandom numbers between 0 and 1.@stdlib/random-base/minstd-shuffle: A linear congruential pseudorandom number generator (LCG) whose output is shuffled.@stdlib/random-strided/minstd-shuffle: fill a strided array with pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG) whose output is shuffled.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-2026. The Stdlib Authors.
FAQs
Create an array containing pseudorandom numbers generated using a linear congruential pseudorandom number generator (LCG) whose output is shuffled.
We found that @stdlib/random-array-minstd-shuffle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.