[TOC]

quantile

Quantile

Introduction

Given the non-NaN numbers sorted in ascending order. Then, corresponds to the quantile , denoted by . For example, for a sorted sequence of 5 numbers, they correspond to , , , and , respectively. In general, the quantile , where , is given by interpolation:

Usage

x = quantile(A, q)

x = quantile(A, p, 'all')

x = quantile(A, p, dim)

x = quantile(A, p, dimVec)

Discussion

When computing a quantile of a set of numbers, all NaN values are removed from the set before performing the computation. If the set is empty after the removal of NaN values, an NaN will be returned as the output.

Examples

Input
a=rand(2,3,4)
x=quantile(a,[10 20 30 40] * 0.01)
Output

a(:, :, 1) = 1e-1 ×
 2.0711   9.1147   7.5377
 8.2067   9.4177   0.8654

a(:, :, 2) = 1e-1 ×
 8.2799   7.3872   1.4412
 0.4373   9.6350   7.7508

a(:, :, 3) = 1e-1 ×
 6.6587   4.9619   2.3629
 1.8065   2.5954   2.8663

a(:, :, 4) = 1e-1 ×
 3.7219   3.0862   7.1284
 3.6086   6.9071   6.5927

x(:, :, 1) = 1e-1 ×
 2.0711   9.1147   0.8654
 2.0711   9.1147   0.8654
 2.6847   9.1450   1.5327
 3.9118   9.2056   2.8671

x(:, :, 2) = 1e-1 ×
 0.4373   7.3872   1.4412
 0.4373   7.3872   1.4412
 1.2216   7.6120   2.0721
 2.7901   8.0616   3.3341

x(:, :, 3) = 1e-1 ×
 1.8065   2.5954   2.3629
 1.8065   2.5954   2.3629
 2.2917   2.8321   2.4132
 3.2621   3.3054   2.5139

x(:, :, 4) = 1e-1 ×
 3.6086   3.0862   6.5927
 3.6086   3.0862   6.5927
 3.6200   3.4683   6.6463
 3.6426   4.2325   6.7534
Input
a=rand(2,3,4)
x=quantile(a,[10 20 30 40] * 0.01,2)
Output
a(:, :, 1) = 1e-1 ×
 5.4991   5.6710   8.9774
 5.7987   5.5879   4.6090

a(:, :, 2) = 1e-1 ×
 7.5114   8.4010   8.3770
 0.1907   2.0860   4.2590

a(:, :, 3) = 1e-1 ×
 4.0253   6.8010   1.8290
 2.8301   0.9264   4.0676

a(:, :, 4) = 1e-1 ×
 5.7757   7.7034   8.7879
 9.4666   8.2765   8.8977

x(:, :, 1) = 1e-1 ×
 5.4991   5.5163   5.5679   5.6195
 4.6090   4.7069   5.0006   5.2942

x(:, :, 2) = 1e-1 ×
 7.5114   7.5980   7.8577   8.1174
 0.1907   0.3802   0.9488   1.5174

x(:, :, 3) = 1e-1 ×
 1.8290   2.0487   2.7075   3.3664
 0.9264   1.1168   1.6879   2.2590

x(:, :, 4) = 1e-1 ×
 5.7757   5.9685   6.5468   7.1251
 8.2765   8.3386   8.5250   8.7113
Input
a=rand(2,3,4)
x=quantile(a,[10 20 30 40] * 0.01,'all')
Output
a(:, :, 1) = 1e-1 ×
 6.0797   1.1510   9.2457
 0.5870   5.0227   1.6294

a(:, :, 2) = 1e-1 ×
 0.6660   0.5263   3.3619
 4.9154   3.0374   3.7822

a(:, :, 3) = 1e-1 ×
 1.7551   2.4141   5.7546
 1.4208   5.8595   5.1658

a(:, :, 4) = 1e-1 ×
 7.5946   1.6099   4.2575
 0.4456   7.2544   3.8506

x = 1e-1 × 
 0.5809
 1.2320
 1.6236
 2.4764
Input
a=rand(2,3,4)
x=quantile(a,[10 20 30 40 50] * 0.01,[1 2])
Output
a(:, :, 1) = 1e-1 ×
 8.1641   0.9487   7.6470
 8.2029   5.4701   8.9867

a(:, :, 2) = 1e-1 ×
 0.0313   1.3611   5.7518
 6.6171   0.6510   7.4514

a(:, :, 3) = 1e-1 ×
 3.5090   9.4290   1.7631
 6.1744   1.7446   8.1828

a(:, :, 4) = 1e-1 ×
 6.0778   2.1679   0.1072
 1.1016   7.9887   2.6365

x(:, :, 1) = 1e-1 ×
 1.4009
 4.1137
 6.1232
 7.4293
 7.9056

x(:, :, 2) = 1e-1 ×
 0.0933
 0.4651
 0.8640
 1.2901
 3.5564

x(:, :, 3) = 1e-1 ×
 1.7465
 1.7576
 2.2869
 3.3344
 4.8417

x(:, :, 4) = 1e-1 ×
 0.2066
 0.8033
 1.4215
 2.0613
 2.4022