Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

math-helper-functions

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-helper-functions

Helper with misc. math functions such as sums, averages, max, min, etc

  • 1.7.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
149
decreased by-62.75%
Maintainers
1
Weekly downloads
 
Created
Source

MathFunctions

Kind: global class

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

ParamTypeDescription
arrayArrayArray to find max value of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

MathFunctions.calcSum(array, [property]) ⇒ number

Returns the sum of an array

Kind: static method of MathFunctions
Returns: number - Sum of array values

ParamTypeDescription
arrayArrayArray to find sum of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

MathFunctions.calcMin(array, [property]) ⇒ number

Returns min value in array

Kind: static method of MathFunctions
Returns: number - Min array value

ParamTypeDescription
arrayArrayArray to find min value of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

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

ParamTypeDescription
arrayArrayArray to calc domain of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

MathFunctions.calcMedian(array, [property]) ⇒ number

Returns median value of array

Kind: static method of MathFunctions
Returns: number - Median of an array

ParamTypeDescription
arrayArrayArray to find median of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

MathFunctions.calcWeightedMedian(array, valueProperty, weightProperty) ⇒ number

Returns weighted median of array

Kind: static method of MathFunctions
Returns: number - Weighted median

ParamTypeDescription
arrayArray.<object>Array to find weighted median of
valuePropertystringProperty to use for array item value
weightPropertystringProperty 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

ParamTypeDescription
arrayArrayArray to find mean of
[property]stringProperty to access in object arrays. Supports nested properties (ex: 'propA.propB')

MathFunctions.calcWeightedMean(array, valueProperty, weightProperty) ⇒ number

Returns weighted mean of array

Kind: static method of MathFunctions
Returns: number - Weighted mean

ParamTypeDescription
arrayArray.<object>Array to find weighted mean of
valuePropertystringProperty to use for array item value
weightPropertystringProperty 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

ParamTypeDescription
toCalcnumberNumber to find percent of
totalnumberTotal

MathFunctions.calcDistribution(array, [numOfBins]) ⇒ Object

Gets array distribution

Kind: static method of MathFunctions
Returns: Object - Distribution of the array's values

ParamTypeDescription
arrayArray.<number>Array to find distribution of
[numOfBins]numberNumber 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

ParamTypeDescription
arrayArray.<any>Array to find quartiles of
[property]stringProperty 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

ParamTypeDefaultDescription
arrayArray.<any>Array to get histogram from
[numberOfBins]number4Number of bins to distribute data
[property]stringProperty 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

ParamTypeDescription
ifThisnumberFirst premise
isThisnumberFirst result
thenThatnumberSecond premise

Keywords

FAQs

Package last updated on 20 Nov 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc