แก้วงเล็บ
This commit is contained in:
@@ -24,10 +24,10 @@ export function takeSampleFrom(sourceList, amount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < amount; ++i) {
|
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.
|
// Re-random until suitable value is found.
|
||||||
while (randElements.includes(rand)) {
|
while (randElements.includes(rand)) {
|
||||||
rand = sourceList[Math.floor((Math.random() * max))];
|
rand = sourceList[Math.floor(Math.random() * max)];
|
||||||
}
|
}
|
||||||
randElements.push(rand);
|
randElements.push(rand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ export default function () {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rand = Math.floor((Math.random() * max));
|
let rand = Math.floor(Math.random() * max);
|
||||||
// Re-random until suitable value is found.
|
// Re-random until suitable value is found.
|
||||||
while (randElements.includes(rand) || exclude.includes(rand)) {
|
while (randElements.includes(rand) || exclude.includes(rand)) {
|
||||||
rand = Math.floor((Math.random() * max));
|
rand = Math.floor(Math.random() * max);
|
||||||
}
|
}
|
||||||
randElements.push(rand);
|
randElements.push(rand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export default function() {
|
|||||||
let u = 2 * Math.random() - 1;
|
let u = 2 * Math.random() - 1;
|
||||||
let v = 2 * Math.random() - 1;
|
let v = 2 * Math.random() - 1;
|
||||||
let r = u * u + v * v;
|
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);
|
return u * Math.sqrt(-2 * Math.log(r) / r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export default function() {
|
|||||||
* @return {Float64Array} - array of zeros with length n.
|
* @return {Float64Array} - array of zeros with length n.
|
||||||
*/
|
*/
|
||||||
function zeros(n) {
|
function zeros(n) {
|
||||||
if (typeof(n) === 'undefined' || isNaN(n)) {
|
if (typeof n === 'undefined' || isNaN(n)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return new Float64Array(n); // typed arrays are faster
|
return new Float64Array(n); // typed arrays are faster
|
||||||
|
|||||||
Reference in New Issue
Block a user