I want to do soft-binning for a distance-based histogram. For example a point X lies somewhere between the center points of 4 bins, A,B,C,D. These four points A,B,C,D can be treated as the vertices of a square.
I would like to assign each of these vertex points a certain weightage (between 0-1) based how much the point X is closer to that vertex with two conditions:
Sum of all vertex weights should be 1.
If X lies on the line between two vertices, only those two vertices should get the share in weightage.
Currently I calculate the weightage as:
W(A) = (1 - distance of A from X/sum of distances of all vertices from X )/3
You can do bilinear interpolation. For a point $(x,y)$in the unit square, the weight at $(0,0)$ is $(1-x)(1-y)$, the weight at $(1,0)$ is $x(1-y)$ and so on. The weights sum to $1$ and are zero when the point is on the opposite edge of the square.