[TOC]

prctile

Percentile

Introduction

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

Usage

x = prctile(A, p)

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

x = prctile(A, p, dim)

x = prctile(A, p, dimVec)

Discussion

Examples

Input
a=rand(2,3,4)
x=prctile(a,[10 20 30 40])
Output
a(:, :, 1) = 1e-1 ×
 0.1156   6.7653   4.9108
 2.3788   2.6566   0.8077

a(:, :, 2) = 1e-1 ×
 3.7458   3.4646   4.8375
 1.8597   4.5208   5.4327

a(:, :, 3) = 1e-1 ×
 2.4835   8.7129   9.9538
 3.6393   8.3322   8.1966

a(:, :, 4) = 1e-1 ×
 2.3323   1.8016   6.4214
 8.7984   9.9092   7.0598

x(:, :, 1) = 1e-1 ×
 0.1156   2.6566   0.8077
 0.1156   2.6566   0.8077
 0.3420   3.0674   1.2180
 0.7946   3.8892   2.0386

x(:, :, 2) = 1e-1 ×
 1.8597   3.4646   4.8375
 1.8597   3.4646   4.8375
 2.0483   3.5702   4.8970
 2.4255   3.7814   5.0160

x(:, :, 3) = 1e-1 ×
 2.4835   8.3322   8.1966
 2.4835   8.3322   8.1966
 2.5991   8.3703   8.3723
 2.8302   8.4464   8.7237

x(:, :, 4) = 1e-1 ×
 2.3323   1.8016   6.4214
 2.3323   1.8016   6.4214
 2.9789   2.6124   6.4853
 4.2722   4.2339   6.6129
Input
a=rand(2,3,4)
x=prctile(a,[10 20 30 40],2)
Output
a(:, :, 1) = 1e-1 ×
 7.4298   4.9368   5.2870
 2.0197   7.5970   5.8044

a(:, :, 2) = 1e-1 ×
 1.2582   1.4798   6.7922
 8.9082   3.3142   8.3416

a(:, :, 3) = 1e-1 ×
 3.7760   7.5272   6.3566
 0.2636   9.8906   8.1573

a(:, :, 4) = 1e-1 ×
 2.4287   0.3615   1.7322
 3.5149   5.9838   1.4551

x(:, :, 1) = 1e-1 ×
 4.9368   4.9718   5.0769   5.1820
 2.0197   2.3982   3.5336   4.6690

x(:, :, 2) = 1e-1 ×
 1.2582   1.2804   1.3468   1.4133
 3.3142   3.8169   5.3252   6.8334

x(:, :, 3) = 1e-1 ×
 3.7760   4.0341   4.8082   5.5824
 0.2636   1.0530   3.4211   5.7892

x(:, :, 4) = 1e-1 ×
 0.3615   0.4985   0.9098   1.3210
 1.4551   1.6610   2.2790   2.8970
Input
a=rand(2,3,4)
x=prctile(a,[10 20 30 40],'all')
Output
a(:, :, 1) = 1e-1 ×
 6.7321   7.9782   6.0957
 9.4546   1.6835   9.5854

a(:, :, 2) = 1e-1 ×
 5.7466   6.6768   8.8506
 2.2872   1.7792   6.3388

a(:, :, 3) = 1e-1 ×
 1.4919   4.1950   9.8525
 4.8302   2.8354   7.5813

a(:, :, 4) = 1e-1 ×
 6.6113   3.7544   3.4085
 8.2217   6.0898   3.2686

x = 1e-1 × 
 1.7696
 2.9653
 3.6506
 4.9218
Input
a=rand(2,3,4)
x=prctile(a,[10 20 30 40 50],[1 2])
Output
a(:, :, 1) = 1e-1 ×
 5.4080   1.7692   6.1000
 3.4720   6.7901   8.2008

a(:, :, 2) = 1e-1 ×
 2.1438   3.9327   3.7100
 9.9937   6.5944   4.2401

a(:, :, 3) = 1e-1 ×
 0.2577   7.8363   4.6556
 5.2031   3.0462   7.9965

a(:, :, 4) = 1e-1 ×
 0.2298   7.5364   8.2895
 1.4242   6.0685   2.8671

x(:, :, 1) = 1e-1 ×
 1.9394
 2.9612
 4.0528
 5.2144
 5.7540

x(:, :, 2) = 1e-1 ×
 2.3004
 3.2401
 3.7768
 3.9104
 4.0864

x(:, :, 3) = 1e-1 ×
 0.5365
 2.2096
 3.5290
 4.4947
 4.9294

x(:, :, 4) = 1e-1 ×
 0.3492
 1.0659
 1.8571
 2.7228
 4.4678