@mapbox/speed-percentile

2.0.1 • Public • Published

speed-percentile

Build Status

A JavaScript utility to compute percentile speed from speed histogram.

Install

npm install @mapbox/speed-percentile

Test

cd to speed-percentile folder then run

npm test

Use

v1.x

var o1 = percentile(P1, P2, P3)

Computes the p-th precentile speed from a sparse hash speed histogram.

Inputs:

param data type description
P1 associative array with integer keys speed histogram hash {<speed>:<count>}
P2 number or array one or more percentiles in decimal
P3 string algorithm flag (optional): 'R4', 'R5' (default)

Algorithms:

Outputs:

output data type description
o1 number or array corresponding speed(s) sorted in descending order

v2.x

v2.x only has R5 algorithm.

var PercentileInterpolator = require('@mapbox/speed-percentile');

var hist = {10: 2, 30: 3, 40: 4};
var pi = new PercentileInterpolator(hist);  

// find speed from percentile
var speed = pi.getSpeed(0.7);
var speeds = pi.getSpeed([0.1, 0.7]);  // irrespective of input order, output is always in descending order

// find percentile from speed
var p = pi.getPercentile(30);
var ps = pi.getPercentile([20, 30]);   // irrespective of input order, output is always in descending order

/@mapbox/speed-percentile/

    Package Sidebar

    Install

    npm i @mapbox/speed-percentile

    Weekly Downloads

    0

    Version

    2.0.1

    License

    ISC

    Last publish

    Collaborators

    • mbx-npm-ci-production
    • mbx-npm-ci-staging
    • mbx-npm-advanced-actions-production
    • mbx-npm-advanced-actions-staging
    • mbx-npm-09-production
    • mbx-npm-08-production
    • mbx-npm-07-production
    • mbx-npm-06-production
    • mbx-npm-05-production
    • mbx-npm-04-production
    • mbx-npm-03-production
    • mbx-npm-02-production
    • mbx-npm-01-production
    • mbx-npm-02-staging
    • mapbox-npm-01
    • mapbox-npm-02
    • mapbox-npm-07
    • mapbox-npm-03
    • mapbox-npm-04
    • mapbox-npm-09
    • mapbox-npm-05
    • mapbox-npm-06
    • mapbox-npm-08
    • mapbox-npm-advanced-actions
    • mapbox-npm-ci
    • mapbox-npm
    • mapbox-admin
    • mapbox-machine-user