Quantiles of labeled categorical laws #
Real labels need neither be distinct nor respect an order on categories. The mass of a label adds all the weights in its fibre. Quantiles are finite cumulative crossings among the distinct positive-weight labels, and their endpoint limits are the smallest and largest such labels.
References #
- N. L. Johnson, S. Kotz, N. Balakrishnan, Discrete Multivariate Distributions, Wiley, 1997, Chapter 35.
A real number is the quantile of a categorical law with supplied real labels exactly when the level strictly exceeds the total weight of smaller labels and is at most the total weight of labels no larger than it. This sorts distinct labels and aggregates equal labels automatically.
As the level tends to zero from above, categorical quantiles tend to any least label whose category has positive weight. Zero-weight categories do not affect the endpoint.
As the level tends to one from below, categorical quantiles tend to any greatest label whose category has positive weight. Zero-weight categories do not affect the endpoint.
Compute a categorical quantile by taking the minimum of the distinct positive-weight labels whose cumulative weight reaches the level.