next up previous [pdf]

Next: Linear interpolation Up: FAMILIAR OPERATORS Previous: Nearest-neighbor coordinates

Data-push binning

Binning is putting data values in bins. Nearest-neighbor binning is an operator. There is both a forward operator and its adjoint. Normally the model consists of values given on a uniform mesh, and the data consists of pairs of numbers (ordinates at coordinates) sprinkled around in the continuum (although sometimes the data is uniformly spaced and the model is not).

In both the forward and the adjoint operation, each data coordinate is examined and the nearest mesh point (the bin) is found. For the forward operator, the value of the bin is added to that of the data. The adjoint is the reverse: we add the value of the data to that of the bin. Both are shown in two dimensions in subroutine bin2().

user/gee/bin2.c
    for (id=0; id < nd; id++) {
        i1 = 0.5 + (xy[0][id]-o1)/d1;
	i2 = 0.5 + (xy[1][id]-o2)/d2;
        if (0<=i1 && i1<m1 &&
            0<=i2 && i2<m2) {
	    im = i1+i2*m1;	    
	    if (adj) mm[im] += dd[id];
	    else     dd[id] += mm[im];
	}
    }
The most typical application requires an additional step, inversion. In the inversion applications each bin contains a different number of data values. After the adjoint operation is performed, the inverse operator divides the bin value by the number of points in the bin. It is this inversion operator that is generally called binning. To find the number of data points in a bin, we can simply apply the adjoint of bin2() to pseudo data of all ones.


next up previous [pdf]

Next: Linear interpolation Up: FAMILIAR OPERATORS Previous: Nearest-neighbor coordinates

2009-03-16