MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / convergenceStep

Method convergenceStep

JSAT/src/jsat/clustering/MeanShift.java:317–345  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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()

Callers 2

mainLoopMethod · 0.95
runMethod · 0.95

Calls 9

sizeMethod · 0.65
kPrimeMethod · 0.65
getNearbyRawMethod · 0.45
zeroOutMethod · 0.45
getPairMethod · 0.45
mutableAddMethod · 0.45
mutableDivideMethod · 0.45
pNormDistMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected