Quantiles
quantile(input: any[] | Mat | Tensor, x: Number) : any[]
param input
a JS array, matrix or tensor, where the data is stored to find the quantiles of
param x
a number in the interval [0, 1] - defines the quantile
returns - any[]
- an array representing the quantile (all the numbers that fall below the quantile limit)
The quantile is a descriptive statistic that is relatively easy to understand, once seen an example of. Note that it is similar to the percentile, another function in this book. The quantile is a number between 0 and 1 that effectively cuts the disitrubtion of points or values in an array evenly and labels them with their appropriate quantile. For example, taking all the array's data in order, splitting it in half evenly, and taking the middle point is quantile 0.5. In other words median = 0.5 quantile. Hence, iqr (interquartile ranges) are also related to quantiles.
Quartiles are quantiles cut at 1/4 parts - 0.25, 0.50, 0.75. The other quantiles are arbitrary. Overall, if you want to find the bottom y
% of data, you can simply call quantile(input, y/100)
. That is because y/100 converts a percentage value into a quantile value. For example, if I want the bottom 23% of values in my 2d array called mat31
, I would simply call quantile(mat31, .23)
. This gives me the .23 quantile of the input.