# Classes: classes

### 8.1.9 Classes: classes

The classes command groups a collection of numbers into intervals.

- classes takes two or three arguments:
  - L, a list or matrix of numbers.
  - Optionally, a and b, numbers. (By default, these will be class_min and class_size from the graphics configuration, see Section 2.5.8, which themselves default to 0 and 1.)
    or:
  - Optionally, a and M, where a is the start of the beginning interval and M consists of the midpoints of the intervals.
    or:
  - Optionally, I, a list of intervals to use.
- classes(L,a,b) returns the list [[a..a+b,n1],[a+b..a+2b,n2],…] where each number in L is in one of the intervals [a+kb, a+(k+1)b) and nk is how many numbers from L are in the corresponding interval.
- classes(L,a,M) returns a similar list, but instead of [[a..a+b,n1],[a+b..a+2b,n2],…], the intervals are determined by a and the list of midpoints M.
- classes(L,I) returns a similar list, but instead of [[a..a+b,n1],[a+b..a+2b,n2],…], the intervals are given by I. In this case, not every element of L is necessarily in an interval.

#### Examples.

- Input:
  classes([0,0.5,1,1.5,2,2.5,3,3.5,4],0,2)
  Output:

  ⎡
  ⎢
  ⎢
  ⎣

  0.0… 2.0 | 4
  2.0… 4.0 | 4
  4.0… 6.0 | 1

  ⎤
  ⎥
  ⎥
  ⎦

- Input:
  classes([0,0.5,1,1.5,2,2.5,3,3.5,4],-1,2)
  Output:

  ⎡
  ⎢
  ⎢
  ⎣

  −1.0… 1.0 | 2
  1.0… 3.0 | 4
  3.0… 5.0 | 3

  ⎤
  ⎥
  ⎥
  ⎦

- Input:
  classes([0,0.5,1,1.5,2,2.5,3,3.5,4],1,[1,3,5])
  Output:

  ⎡
  ⎢
  ⎢
  ⎣

  0.0… 2.0 | 4
  2.0… 4.0 | 4
  4.0… 6.0 | 1

  ⎤
  ⎥
  ⎥
  ⎦

- Input:
  classes([0,0.5,1,1.5,2,2.5,3,3.5,4],[1..3,3..6])
  Output:

  ⎡
  ⎢
  ⎣

  1… 3 | 4
  3… 6 | 3

  ⎤
  ⎥
  ⎦