Search code examples
2daveragearea

How to get an average from layout of pts


Consider the following image:

Diagram

How would I get the "average" (unknown what this is called) of a point on this plane? For example, if I was in between 23, 15, 45, and 34 on that grid, it would average all them together weighted by distance to each. For example, here I'd expect something like 25.

This is really difficult to explain and feel free to ask any questions you have.

Thanks so much for the help, Kidovate


Solution

  • I'm not sure I did understand what you mean but - if I did - you may try to use a kNN algorithm. For example if that points are known values and you want to "guess" the value of an arbitrary point you can use that algorithm. Basically you have to calculate the distance of each known point from the point you're calculating then sort the vector by distance and keep first k items (k Nearest Neighbors). Then you can simply use a weighted mean. As start point: http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation