File Exchange

image thumbnail

Group Equally

version 1.0 (1.66 KB) by

Categorise data into quantiles

1 Download


View License

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.

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.


Comments and Ratings (0)

MATLAB Release
MATLAB 7.1.0 (R14SP3)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video