Package Exports
- math-helper-functions
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (math-helper-functions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
MathFunctions
Kind: global class
- MathFunctions
- new MathFunctions()
- .calcMax(array, [property]) ⇒
number - .calcSum(array, [property]) ⇒
number - .calcMin(array, [property]) ⇒
number - .calcDomain(array, [property]) ⇒
Array.<number> - .calcMedian(array, [property]) ⇒
number - .calcWeightedMedian(array, valueProperty, weightProperty) ⇒
number - .calcMean(array, [property]) ⇒
number - .calcWeightedMean(array, valueProperty, weightProperty) ⇒
number - .calcPercent(toCalc, total) ⇒
number - .calcDistribution(array, [numOfBins]) ⇒
object - .calcQuartiles(array, [property]) ⇒
Array.<number> - .calcHistogram(array, [numberOfBins], [property]) ⇒
Array.<number> - .ruleOfThree(ifThis, isThis, thenThat) ⇒
number
new MathFunctions()
MathFunctions class Compendium of math-related functions
MathFunctions.calcMax(array, [property]) ⇒ number
Returns array max value
Kind: static method of MathFunctions
Returns: number - Max array value
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array |
Array to find max value of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcSum(array, [property]) ⇒ number
Returns the sum of an array
Kind: static method of MathFunctions
Returns: number - Sum of array values
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array |
Array to find sum of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcMin(array, [property]) ⇒ number
Returns min value in array
Kind: static method of MathFunctions
Returns: number - Min array value
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array |
Array to find min value of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcDomain(array, [property]) ⇒ Array.<number>
Returns min and max values in array
Kind: static method of MathFunctions
Returns: Array.<number> - Min and max values in array
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array.<string> | Array.<number> |
Array to calc domain of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcMedian(array, [property]) ⇒ number
Returns median value of array
Kind: static method of MathFunctions
Returns: number - Median of an array
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array |
Array to find median of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcWeightedMedian(array, valueProperty, weightProperty) ⇒ number
Returns weighted median of array
Kind: static method of MathFunctions
Returns: number - Weighted median
| Param | Type | Description |
|---|---|---|
| array | Array.<object> |
Array to find weighted median of |
| valueProperty | string |
Property to use for array item value |
| weightProperty | string |
Property to use for array item weight |
MathFunctions.calcMean(array, [property]) ⇒ number
Returns mean value of array
Kind: static method of MathFunctions
Returns: number - Mean of an array
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array |
Array to find mean of | |
| [property] | string |
null |
Property name to iterate |
MathFunctions.calcWeightedMean(array, valueProperty, weightProperty) ⇒ number
Returns weighted mean of array
Kind: static method of MathFunctions
Returns: number - Weighted mean
| Param | Type | Description |
|---|---|---|
| array | Array.<object> |
Array to find weighted mean of |
| valueProperty | string |
Property to use for array item value |
| weightProperty | string |
Property to use for array item weight |
MathFunctions.calcPercent(toCalc, total) ⇒ number
Calculate percentage using rule of three
Kind: static method of MathFunctions
Returns: number - Percentage
| Param | Type | Description |
|---|---|---|
| toCalc | number |
Number to find percent of |
| total | number |
Total |
MathFunctions.calcDistribution(array, [numOfBins]) ⇒ object
Gets array distribution
Kind: static method of MathFunctions
Returns: object - Distribution of the array's values
| Param | Type | Description |
|---|---|---|
| array | Array.<number> |
Array to find distribution of |
| [numOfBins] | number |
Number of bins to use (optional) |
MathFunctions.calcQuartiles(array, [property]) ⇒ Array.<number>
Calcs quartiles of data array
Kind: static method of MathFunctions
Returns: Array.<number> - [min, mean, max] quartiles
| Param | Type | Description |
|---|---|---|
| array | Array.<any> |
Array to find quartiles of |
| [property] | string |
Property to access in object arrays. Supports nested properties (ex: 'propA.propB') |
MathFunctions.calcHistogram(array, [numberOfBins], [property]) ⇒ Array.<number>
Calcs histogram from data array
Kind: static method of MathFunctions
Returns: Array.<number> - Distribution data array
| Param | Type | Default | Description |
|---|---|---|---|
| array | Array.<any> |
Array to get histogram from | |
| [numberOfBins] | number |
4 |
Number of bins to distribute data |
| [property] | string |
Property to access in object arrays. Supports nested properties (ex: 'propA.propB') |
MathFunctions.ruleOfThree(ifThis, isThis, thenThat) ⇒ number
Performs a rule of three calculation
Kind: static method of MathFunctions
Returns: number - The result of the rule of three
| Param | Type | Description |
|---|---|---|
| ifThis | number |
First premise |
| isThis | number |
First result |
| thenThat | number |
Second premise |