sample = {
let s = prop.reduce((a,b)=>a+b);
let n = prop.length;
let threshold = prop.map((x,i) => prop.slice(0,i+1).reduce((a,b)=>a+b) /s);
return () => {
let x = Math.random();
for (let i = 0; i < threshold.length; i++) {
let t = threshold[i];
if (x <= t) return i;
}
}
}