prctilePercentile
Given the non-NaN numbers
x = prctile(A, p)p should be a vector of real numbers lying in A is a scalar, x is a vector with length length(p). Each element of x is equal to A.A is a vector, x is a vector with length length(p) where x(i) is equal to the p(i)-th percentile of A.A is a matrix or multi-dimensional array, it takes each vector of A along its first non-singleton dimension, and computes the vector's percentiles. The vector collapses or expands into a vector of length length(p) storing the percentiles.size(x,k) == length(p) holds, where k is the first non-singleton dimension of A, whereas size(x,i) == size(A,i) holds for all i not equal to k. quantile(A, p/100).x = prctile(A, p, 'all')p should be a vector of real numbers lying in x is a vector, where x(i) gives the p(i)-th percentile of the data set containing all numbers in A.x and p have the same lengths.quantile(A, p/100, 'all').x = prctile(A, p, dim)p should be a vector of real numbers lying in A along its dim-th dimension and computes the vector's percentiles. The vector collapses or expands into a vector of lengthlength(p) storing the percentiles.size(x,dim) == length(p) hold, whereas size(x,i) == size(A,i) holds for all i not equal to dim. quantile(A, p/100, dim).x = prctile(A, p, dimVec)p should be a vector of real numbers lying in dimVec(1), dimVec(2), ..., dimVec(end) and compute the elements' percentiles.quantile(A, p/100, dimVec)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.prctile takes each column (first non-singleton dimension) of a and then computes the column's percentiles. Since p has 4 numbers, each column of x also has length 4.a=rand(2,3,4)
x=prctile(a,[10 20 30 40])
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
prctile takes each row (2nd dimension) of a and then computes the row's percentiles. Since p has 4 numbers, each row of x also has length 4.a=rand(2,3,4)
x=prctile(a,[10 20 30 40],2)
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
prctile takes all numbers in a and then computes their percentiles. Since p has 4 numbers, the array a is collapsed into a vector of length 4.a=rand(2,3,4)
x=prctile(a,[10 20 30 40],'all')
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
prctile takes all numbers in a plane spanning the 1st (row) and 2nd (column) dimensions and then computes the numbers' percentiles. The array a has 4 such planes, therefore the output x has length 4 along the direction of the 3rd dimension (pointing into the screen). Since p has 5 numbers, each of the planes collapses into a vector of 5 numbers.a=rand(2,3,4)
x=prctile(a,[10 20 30 40 50],[1 2])
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