Compute a frequency table.
For vector data, the function counts the number of values in data that fall between the elements in the edges vector (which must contain monotonically non-decreasing values). table is a matrix. The first column of table is the number of bin, the second is the number of instances in each class (absolute frequency). The third column contains the percentage of each value (relative frequency) and the fourth column contains the cumulative frequency.
If edges is missed the width of each class is unitary, if edges is a scalar then represent the number of classes, or you can define the width of each bin. table(k, 2) will count the value data (i) if edges (k) <= data (i) < edges (k+1). The last bin will count the value of data (i) if edges(k) <= data (i) <= edges (k+1). Values outside the values in edges are not counted. Use -inf and inf in edges to include all values. Tabulate with no output arguments returns a formatted table in the command window.
Example
sphere_radius = [1:0.05:2.5]; tabulate (sphere_radius)
Tabulate returns 2 bins, the first contains the sphere with radius between 1 and 2 mm excluded, and the second one contains the sphere with radius between 2 and 3 mm.
tabulate (sphere_radius, 10)
Tabulate returns ten bins.
tabulate (sphere_radius, [1, 1.5, 2, 2.5])
Tabulate returns three bins, the first contains the sphere with radius between 1 and 1.5 mm excluded, the second one contains the sphere with radius between 1.5 and 2 mm excluded, and the third contains the sphere with radius between 2 and 2.5 mm.
bar (table (:, 1), table (:, 2))
draw histogram.
See also: bar, pareto.
Package: statistics