Group: | Binning, Grids and Sequences |
See also: | aseq conv distance grid mseq |
Function: | bindata | |
Description: | Bins a p-dimensional data set x, starting from the origin orig in steps of d. |
Usage: | {xb, yb} = bindata (x, d, orig {,y}) | |
Input: | ||
x | m x n x d1 x ... x dn array | |
d | n x 1 x d1 x ... x dn array | |
orig | n x 1 x d1 x ... x dn array | |
y | m x p x d1 x ... x dn array | |
Output: | ||
xb | l x n x d1 x ... x dn array, the indices of the bins into which the | |
yb | l x (p+1) x d1 x ... x dn array |
The binning parameter d can be a scalar or a p-vector which gives a specific step for each column xj (j=1,...,p).
The output matrix xb contains the index of the nonempty bins.
The output matrix yb contains in the first column the absolute frequency of datapoints xij in each nonempty bin.
If the optional parameter y (a n x L matrix) is given, then the sum of those y_i's (i=1,...,n) such that the corresponding x_ij lies in a bin is given back respectively on the last L columns of yb.
library("xplore") x=aseq(0,10,0.1) y=aseq(2,10,0.2) z=x~y d=#(0.4,0.8) org=#(0.05,1.95) bindata(z,d,org)
Contents of bindata.xb [ 1,] -1 0 [ 2,] 0 0 [ 3,] 0 0 [ 4,] 0 0 [ 5,] 0 1 [ 6,] 1 1 [ 7,] 1 1 [ 8,] 1 1 [ 9,] 1 2 [10,] 2 2 Contents of bindata.yb [ 1,] 1 [ 2,] 3 [ 3,] 0 [ 4,] 0 [ 5,] 1 [ 6,] 3 [ 7,] 0 [ 8,] 0 [ 9,] 1