diff --git a/examples/js/src/neighbourSampling-papaparsing/neighbourSampling.js b/examples/js/src/neighbourSampling-papaparsing/neighbourSampling.js index 08db9bf..2f9a652 100644 --- a/examples/js/src/neighbourSampling-papaparsing/neighbourSampling.js +++ b/examples/js/src/neighbourSampling-papaparsing/neighbourSampling.js @@ -15,7 +15,7 @@ function startNeighbourSamplingSimulation() { .distance(function (s, t) { return distanceFunction(s, t, props, norm); }) - .stableVelocity(0.000001) + .stableVelocity(0.000001) //TODO .stableVeloHandler(ended); simulation diff --git a/src/interpolation/helpers.js b/src/interpolation/helpers.js index 3c3e74a..8d8ae81 100644 --- a/src/interpolation/helpers.js +++ b/src/interpolation/helpers.js @@ -12,7 +12,7 @@ export function takeSampleFrom(sourceList, amount) { let randElements = [], max = sourceList.length; - if (amount <= max) { + if (amount >= max) { return {sample: sourceList, remainder: {}}; } diff --git a/src/neighbourSamplingDistance.js b/src/neighbourSamplingDistance.js index 120e5af..480153a 100644 --- a/src/neighbourSamplingDistance.js +++ b/src/neighbourSamplingDistance.js @@ -3,7 +3,7 @@ import jiggle from "./jiggle"; import {getStress} from "./stress"; /** - * The implementation of Chalmers' 1996 Neighbour and Sampling algorithm. + * An implementation of Chalmers' 1996 Neighbour and Sampling algorithm. * It uses random sampling to find the most suited neighbours from the * data set. */ @@ -23,7 +23,7 @@ export default function () { dataSizeFactor; /** - * Apply spring forces at each iteration. + * Apply spring forces at each simulation iteration. * @param {number} alpha - multiplier for amount of force applied */ function force(alpha) { @@ -48,7 +48,7 @@ export default function () { for (let [sampleID, highDDist] of samples) { setVelocity(node, nodes[sampleID], highDDist, alpha); } - // Replace neighbours with better ones found in the samples + neighbours[i] = findNewNeighbours(neighbours[i], samples); } @@ -62,6 +62,7 @@ export default function () { velocityDiff /= n*(neighbourSize+sampleSize); if(stableVeloHandler!==null && velocityDiff