I have a program that tests a randomness function for how truly random it is:
function testRandom(randomF, tests, intendedMean){
let total = 0;
for(let t = 0; t < tests; t++){
total+=randomF();
}
return Math.abs((total/tests) - intendedMean);
}
const randomFunc = () => { return ~~(Math.random() * 2) + 1 }
//returns a randomly choosen 1 or 2.
console.log(testRandom(randomFunc, 100, 1.5));
But is their a way to take out the intended mean and still have a relatively accurate output? My ideas so far are to create a standard deviation set up, but I'm not sure that's the right idea.
Aucun commentaire:
Enregistrer un commentaire