math-helper-functions
Advanced tools
Comparing version 1.0.2 to 1.0.3
12
index.js
@@ -119,10 +119,12 @@ const {max, min, mean, median, histogram} = require('d3-array'); | ||
* @param {number[]|string[]} array Array to find distribution of | ||
* @param {number} [numOfBins] Number of bins to use (optional) | ||
* @returns {object} Distribution of the array's values | ||
* @memberof MathFunctions | ||
*/ | ||
static calcDistribution(array) { | ||
let numHelper = new NumberHelper(); | ||
let numArray = array.map((d) => numHelper.processNumber(d)); | ||
let dist = histogram()(numArray); | ||
let graphData = { | ||
static calcDistribution(array, numOfBins) { | ||
const numHelper = new NumberHelper(); | ||
const numArray = array.map((d) => numHelper.processNumber(d)); | ||
const hist = numOfBins ? histogram().thresholds(numOfBins) : histogram(); | ||
const dist = hist(numArray); | ||
const graphData = { | ||
labels: [], | ||
@@ -129,0 +131,0 @@ data: [], |
{ | ||
"name": "math-helper-functions", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Helper with misc. math functions such as sums, averages, max, min, etc", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ <a name="MathFunctions"></a> | ||
- [.calcPercent(toCalc, total)](#MathFunctions.calcPercent) ⇒ <code>Number</code> | ||
- [.calcDistribution(array)](#MathFunctions.calcDistribution) ⇒ <code>object</code> | ||
- [.calcDistribution(array, [numOfBins])](#MathFunctions.calcDistribution) ⇒ <code>object</code> | ||
@@ -126,3 +126,3 @@ <a name="new_MathFunctions_new"></a> | ||
### MathFunctions.calcDistribution(array) ⇒ <code>object</code> | ||
### MathFunctions.calcDistribution(array, [numOfBins]) ⇒ <code>object</code> | ||
@@ -134,4 +134,5 @@ Gets array distribution | ||
| Param | Type | Description | | ||
| ----- | ---------------------------------------------------------------------- | ----------------------------- | | ||
| array | <code>Array.<number></code> \| <code>Array.<string></code> | Array to find distribution of | | ||
| Param | Type | Description | | ||
| ----------- | ---------------------------------------------------------------------- | -------------------------------- | | ||
| array | <code>Array.<number></code> \| <code>Array.<string></code> | Array to find distribution of | | ||
| [numOfBins] | <code>number</code> | Number of bins to use (optional) | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381
136
18061
4