Skip to main content
Module

x/simplestatistics/index.js>quantile

simple statistics for node & browser javascript
Go to Latest
function quantile
import { quantile } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

The quantile: this is a population quantile, since we assume to know the entire dataset in this library. This is an implementation of the Quantiles of a Population algorithm from wikipedia.

Sample is a one-dimensional array of numbers, and p is either a decimal number from 0 to 1 or an array of decimal numbers from 0 to 1. In terms of a k/q quantile, p = k/q - it's just dealing with fractions or dealing with decimal values. When p is an array, the result of the function is also an array containing the appropriate quantiles in input order

Examples

quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9

Parameters

x

sample of one or more numbers

p

the desired quantile, as a number between 0 and 1