UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

41 lines (40 loc) 1.35 kB
import { factory } from '../../utils/factory.js'; import { createQuantileSeq } from '../../function/statistics/quantileSeq.js'; import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js'; var name = 'quantileSeq'; var dependencies = ['typed', 'add', 'multiply', 'partitionSelect', 'compare', 'isInteger']; /** * Attach a transform function to math.quantileSeq * Adds a property transform containing the transform function. * * This transform changed the `dim` parameter of function std * from one-based to zero based */ export var createQuantileSeqTransform = /* #__PURE__ */factory(name, dependencies, _ref => { var { typed, add, multiply, partitionSelect, compare, isInteger } = _ref; var quantileSeq = createQuantileSeq({ typed, add, multiply, partitionSelect, compare, isInteger }); return typed('quantileSeq', { 'Array|Matrix, number|BigNumber|Array, number': (arr, prob, dim) => quantileSeq(arr, prob, dimToZeroBase(dim)), 'Array|Matrix, number|BigNumber|Array, boolean, number': (arr, prob, sorted, dim) => quantileSeq(arr, prob, sorted, dimToZeroBase(dim)) }); function dimToZeroBase(dim) { // TODO: find a better way, maybe lastDimToZeroBase could apply to more cases. return lastDimToZeroBase([[], dim])[1]; } }, { isTransformFunction: true });