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 dpbin2().
# Data-push binning in 2-D.
#
subroutine dpbin2 ( adj, add, o1,d1,o2,d2, xy, mm,m1,m2, dd, nd)
integer i1,i2, adj, add, id, m1,m2, nd
real o1,d1,o2,d2, xy(2,nd), mm(m1,m2), dd( nd)
call adjnull( adj, add, mm,m1*m2, dd, nd)
do id=1,nd {
i1 = 1.5 + (xy(1,id)-o1)/d1
i2 = 1.5 + (xy(2,id)-o2)/d2
if( 1<=i1 && i1<=m1 &&
1<=i2 && i2<=m2 )
if( adj == 0)
dd( id) = dd( id) + mm(i1,i2)
else
mm(i1,i2) = mm(i1,i2) + dd( id)
}
return; end
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 dpbin2() to pseudo data of all ones.