From f316d2755a30eb88db0355fc042b1f81105df7f2 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk <2285135b@student.gla.ac.uk> Date: Thu, 22 Mar 2018 15:48:30 +0000 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=A7=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B9=87=E0=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interpolation/helpers.js | 4 ++-- src/neighbourSampling.js | 4 ++-- src/t-sne.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/interpolation/helpers.js b/src/interpolation/helpers.js index 2bf620c..4d97a4e 100644 --- a/src/interpolation/helpers.js +++ b/src/interpolation/helpers.js @@ -24,10 +24,10 @@ export function takeSampleFrom(sourceList, amount) { } for (let i = 0; i < amount; ++i) { - let rand = sourceList[Math.floor((Math.random() * max))]; + let rand = sourceList[Math.floor(Math.random() * max)]; // Re-random until suitable value is found. while (randElements.includes(rand)) { - rand = sourceList[Math.floor((Math.random() * max))]; + rand = sourceList[Math.floor(Math.random() * max)]; } randElements.push(rand); } diff --git a/src/neighbourSampling.js b/src/neighbourSampling.js index 9914cc2..eb8de26 100644 --- a/src/neighbourSampling.js +++ b/src/neighbourSampling.js @@ -126,10 +126,10 @@ export default function () { break; } - let rand = Math.floor((Math.random() * max)); + let rand = Math.floor(Math.random() * max); // Re-random until suitable value is found. while (randElements.includes(rand) || exclude.includes(rand)) { - rand = Math.floor((Math.random() * max)); + rand = Math.floor(Math.random() * max); } randElements.push(rand); } diff --git a/src/t-sne.js b/src/t-sne.js index 996bf18..3cbade4 100644 --- a/src/t-sne.js +++ b/src/t-sne.js @@ -52,7 +52,7 @@ export default function() { let u = 2 * Math.random() - 1; let v = 2 * Math.random() - 1; let r = u * u + v * v; - if (r == 0 || r > 1) return gaussRandom(); + if (r == 0 || r > 1) {return gaussRandom();} return u * Math.sqrt(-2 * Math.log(r) / r); } @@ -74,7 +74,7 @@ export default function() { * @return {Float64Array} - array of zeros with length n. */ function zeros(n) { - if (typeof(n) === 'undefined' || isNaN(n)) { + if (typeof n === 'undefined' || isNaN(n)) { return []; } return new Float64Array(n); // typed arrays are faster