Group Equally

版本 1.0.0.0 (1.7 KB) 作者: Ged Ridgway
Categorise data into quantiles
472.0 次下载
更新时间 2010/10/4

查看许可证

One can easily split continuous data into two equally sized groups using
g = x > median(x);
this simple function generalises this idea to more than two roughly equal groups using quantiles/percentiles. It returns a group indicator vector of the same length as the input vector suitable for use with functions like boxplot.

Example:
Given n-by-2 matrix of data X, show distribution of second variable within first variable's quartiles
g = group_equally(X(:, 1), 4);
boxplot(X(:, 2), g)

The function is similar to the Stata command "xtile", though might differ due to different definitions of percentiles; this function uses the definition from the reference below.

Reference:
http://www.bmj.com/content/309/6960/996.full

引用格式

Ged Ridgway (2024). Group Equally (https://www.mathworks.com/matlabcentral/fileexchange/28937-group-equally), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14SP3
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0