num-engine
a statistics package in javascript
- lightweight, only 5.83kb
- easy to use
- both browser & node.js
- fast and efficient
Installation
npm install --save num-engine
//in node.jslet NumEngine = ;let numEngine = 12345; //in browserslet numEngine = 12345;
Documentation
Quick Start
let NumEngine = ; //browsers don't need thislet numEngine = 12345 sorted:true //default is false; // config object is optional
{sorted:true} should be added for sorted array arguments to improve performance.
Methods
sum
return the summation value of the array items
let numEngine = 12345;let result = numEngine; // 15
product
return the product of array items
let numEngine = 12345;let result = numEngineproduct;
min
return the minimal value of array items
let numEngine = 12345sorted:true;let result = numEngine;
max
return the maximum value of array items
let numEngine = 12345sorted:true;let result = numEngine;
mean
return the mean of array items
let numEngine = 12345sorted:true;let result = numEngine;
gemoerticMean
return the geometric mean of array items
let numEngine = 12345;let result = numEngine;
mode
return mode of array items
let numEngine = 12345;let result = numEngine;
sort
sort the current array in ascending order and also return the sorted array
let numEngine = 12345;let result = numEngine;
reverseSort
sort the current array in descending order and also return the sorted array
let numEngine = 12345;let result = numEngine;
shuffle
shuffle the current array and also return the shuffled array
let numEngine = 12345;let result = numEngine;
median
return the median of aray items
let numEngine = 12345;let result = numEngine;
chunk(chunkSize:number)
divides the array into sub arrays with chunkSize length
let numEngine = 123456;let result = numEngine;/* result is [ [1,2],[3,4],[5,6] ] */
static differentiate(f:Function)
return the 1st ordered differentiated function of given function
NumEngine
static generateRandomInt(lowerLimit:number,upperLimit:number)
return a random integer
NumEngine;
static generateRandomFloat(lowerLimit:number,upperLimit:number)
return a random float number
NumEngine;
static generateRandomIntArray(count:number,lowerLimit:number,upperLimit:number)
return a random integer number array
NumEngine;
static generateRandomFloatArray(count:number,lowerLimit:number,upperLimit:number)
return a random float number array
NumEngine;
variance
return the variance of the given array
let numEngine = 123456;let result = numEngine;
standardDeviation
return the standard deviation of the given array
let numEngine = 123456;let result = numEngine;
static factorial(startNumber:number)
return the factorial value of a number
NumEngine;
extent
return the min and max value of array items
let numEngine = 123456;let result = numEngine; //[1,6]