const Distance = require("./distance.js"), eudist = Distance.eudist, dist = Distance.dist; module.exports = { kmrand(data,k) { var map = {}, ks = [], t = k<<2; var len = data.length; var multi = data[0].length>0; while(ks.length0) { let d = data[Math.floor(Math.random()*len)]; let key = multi? d.join("_") : `${d}`; if(!map[key]) { map[key] = true; ks.push(d); } } if(ks.length0; var map = {}; // First random centroid var c = data[Math.floor(Math.random()*len)]; var key = multi? c.join("_") : `${c}`; ks.push(c); map[key] = true; // Retrieve next centroids while(ks.lengtha.pr-b.pr); // Cummulative Probabilities prs[0].cs = prs[0].pr; for(let i=1;i= rnd let idx = 0; while(idx