Computes the meanShift of the point at the given index, and then updates the vector array to indicate the movement towards the mode for the data point. @param xit the array of the current data point's positions @param i the index of the data point being considered @param converged the array used to
(final Vec[] xit, int i, final boolean[] converged, final int[] designations, final Vec scratch, final KernelFunction k)
| 315 | * @param k the kernel function to use |
| 316 | */ |
| 317 | private void convergenceStep(final Vec[] xit, int i, final boolean[] converged, final int[] designations, final Vec scratch, final KernelFunction k) |
| 318 | { |
| 319 | double denom = 0.0; |
| 320 | Vec xCur = xit[i]; |
| 321 | List<? extends VecPaired<VecPaired<Vec, Integer>, Double>> contrib = mkde.getNearbyRaw(xCur); |
| 322 | |
| 323 | if(contrib.size() == 1) |
| 324 | { |
| 325 | //If a point has no neighbors, it can not shift, and is its own mdoe - so we mark it noise |
| 326 | converged[i] = true; |
| 327 | designations[i] = -1; |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | scratch.zeroOut(); |
| 332 | for(VecPaired<VecPaired<Vec, Integer>, Double> v : contrib) |
| 333 | { |
| 334 | double g = - k.kPrime(v.getPair()); |
| 335 | denom += g; |
| 336 | scratch.mutableAdd(g, v); |
| 337 | } |
| 338 | scratch.mutableDivide(denom); |
| 339 | |
| 340 | if( Math.abs(scratch.pNormDist(2, xCur)) < 1e-5) |
| 341 | converged[i] = true; |
| 342 | |
| 343 | scratch.copyTo(xCur); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public MeanShift clone() |
no test coverage detected