c++ - inverse distance weighting interpolation -
I would like to calculate a weight in the mutual form of distance for something.
double wgt = 0, wgt_tmp, results = 0; For (int i = 0; i & lt; num; i ++) {wgt_tmp = 1.0 / dist [i]; Wgt + = wgt_tmp; Results + = wgt_tmp * Value [i]; } Result = / wgt;
Although the distance may be 0
and I need to make the weight suitable for compression. If only one distance is dist [i]
, then 0
, I should have a corresponding value of value [i]
dominant < / Strong>. If there are many distances, then 0
for the result, I would like to make their values for contribute evenly , even if dist (i) < / Code> is not zero, but very small, so I want to check it and make appropriate criteria for dealing with it. How to implement any idea?
I do not see any other way than pieces - you get a different distance The simplest thing to do is simply cut off:
modified_dist [i] = dist [i] & lt; MIN_DIST? MIN_DIST: dist [i]
But if you want to, you can change this with a lack of (MIN_DIST + dist [i]) / 2
.
Comments
Post a Comment