Dividing values into equal sized groups

Distribute values, as evenly as possible, over quantile rank groups.
571 Downloads
Updated 14 Apr 2013

View License

Return quantile ranks of the values in a vector based on their sorted order.

usage:
Y = quantileranks(X, q)
Y = quantileranks(X, q, permtie)

X is a vector of values, possibly with NaNs.
q determines quantile class:
q = 4, quartiles ( 4-quantile),
q = 10, deciles (10-quantile),
q = 100, percentiles (100-quantile),
...
permties is a boolean flag to shuffle ranks over duplicate values, ties.
Y is a vector of quantile ranks for the corresponding X values.

example:
>> x=[6 6 3 2 6 6 2 5 NaN 7];
>> [~,ix]=sort(x);
>> y=quantileranks(x,3,0);
>> [x(ix);y(ix)]
ans =
2 2 3 5 6 6 6 6 7 NaN
1 1 1 2 2 2 3 3 3 0
>> tabulate(y)
Value Count Percent
0 1 10.00%
1 3 30.00%
2 3 30.00%
3 3 30.00%

Cite As

Mohammad Rawashdeh (2024). Dividing values into equal sized groups (https://www.mathworks.com/matlabcentral/fileexchange/41266-dividing-values-into-equal-sized-groups), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Tables in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0