BIN command

Syntax: BIN x xbin xcount
BIN\NBINS x xbin xcount n { xmin xmax }
Qualifiers: \WEIGHTS, \EDGES, \NBINS, \DISCARD, \EMPTY, \AVERAGE, \LAGRANGE
Defaults: \-WEIGHTS, \-EDGES, \-NBINS, \-DISCARD, \-EMPTY, \-AVERAGE, \LAGRANGE, xmin = min(x), xmax = max(x)

The BIN command sorts an input vector, x, into a grid of bins and accumulates the counts per bin into an output vector, xcount. Each element of x is considered only once, so elements are never counted as being in more than one bin. By default, the bins are defined by their centers, given in vector xbin, which must be strictly monotonically increasing. If n = LEN(xbin), define the bin ranges, ri

r1 = xbin[1] - (xbin[2] - xbin[1])/2

ri = xbin[i] - (xbin[i] - xbin[i-1])/2  for  i = 2, 3, ..., n

rn+1 = xbin[n] + (xbin[n] - xbin[n-1])/2

For each i = 1, 2, ..., LEN(x), if rj ≤ x[i] < rj+1  for some j = 1, 2, ..., n  then xcount[j] is incremented by 1, or by the weight, w[i]. By default, events below r1 will be placed in the first bin, and events above rn+1 will be placed in the last bin. If the \DISCARD qualifier is used, events outside this range will be discarded.

Weights
Number of bins
Lagrange
Average
Count only if empty
Edge defined bins