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