
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
array-correl
Advanced tools
Generates array of correlated pairs of numbers, and inspects array of such correlated pairs
[![NPM package][npm-img]][npm-url] [![Build Size][build-size-img]][build-size-url]
Generates array of correlated pairs of numbers with desired mean and deviation. It also inspects an array of such correlated pairs and returns the Pearson correlation coefficient, the deviation, mean and extent (min and max)
npm install array-correl
The generate method generates an array of length count with correlated sets of numbers in the { x: xValue, y: yValue } format. Optionally, the following parameters can be specified:
If the correlation coefficient is not specified, it defaults to 0.7; if mean is not specified, it defaults to 0; if deviation is not specified, it defaults to 1.
array-correl.generate(count, [correlation, [mean, [deviation]]]);
If no count argument is passed, a ReferenceError is thrown. If any passed argument is not a number (or cannot be coerced to a number), a TypeError is thrown.
The inspect method analyzes the supplied array and returns several statistics measures. The format of the input array must be one of the following:
{ x: xValue, y: yValue }[ xValue, yValue ]The function returns the following parameters in a JS object:
array-correl.inspect(array);
If no array argument is passed, a ReferenceError is thrown. If the passed array doesn't contain either two-element arrays or objects with x and y properties, a TypeError is thrown.
Example:
// Import methods and version from array-correl from node_modules
const { generate, inspect, version } = require('array-correl');
// Import methods and version from array-correl locally
// const { generate, inspect, version } = require('../src/index.js');
// Log version
console.log(`array-correl version: ${version}`);
// Define inputs to the generate method
const count = 10000;
const correlation = 0.8;
const mean = 100;
const deviation = 1;
// Log inputs
console.log('\nInputs to generate:');
console.log(` count: ${count}`);
console.log(` correlation: ${correlation}`);
console.log(` mean: ${mean}`);
console.log(` deviation: ${deviation}`);
// Create an array with values of correlated pairs of numbers
const array = generate(count, correlation, mean, deviation);
console.log('\nFirst 10 correlated pairs:');
// Log the first 10 array elements
for (let i = 0; i < 10; i++) {
console.log(` ${JSON.stringify(array[i])}`);
}
// Inspect the array
const result = inspect(array);
console.log(`\nOutput of inspect: \n${JSON.stringify(result, null, 2)}\n`);
/*
Example output:
array-correl version: 1.0.0
Inputs to generate:
count: 10000
correlation: 0.8
mean: 100
deviation: 1
First 10 correlated pairs:
{"x":99.71068933565104,"y":99.86127640311815}
{"x":100.83597240809056,"y":100.074669667149}
{"x":102.0130498785201,"y":101.38201755974566}
{"x":100.65061261210614,"y":99.88629765791357}
{"x":98.30631250480867,"y":98.49421518032264}
{"x":99.48427439034523,"y":99.81419151256067}
{"x":98.90338120221003,"y":98.38761587336445}
{"x":101.06519781042032,"y":101.50229105410696}
{"x":98.7248721438115,"y":98.06148966509333}
{"x":99.40834127473076,"y":98.90308575665651}
Output of inspect:
{
"r": 0.802558017048035,
"xDeviation": 1.0004768422899535,
"yDeviation": 0.9984232776109369,
"xExtent": [
95.99318668690016,
103.92406651194449
],
"yExtent": [
96.15152222172428,
103.84111296300848
],
"xMean": 100.00871360178544,
"yMean": 100.00635903137874
}
*/
Run the test suite like so:
npm run test
FAQs
Generates array of correlated pairs of numbers, and inspects array of such correlated pairs
The npm package array-correl receives a total of 12 weekly downloads. As such, array-correl popularity was classified as not popular.
We found that array-correl demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.