Assuming the random() function is random and returns a value in the range [0, 1]. Will the resulting true values be biased towards a direction in the array when using this method?
int chances = 16;
int guaranteed = 6;
boolean[] result = new boolean[chances];
for (int i = 0; i < result.length; i++) {
if (random() <= (float) guaranteed / chances) {
result[i] = true;
guaranteed--;
}
chances--;
}
Aucun commentaire:
Enregistrer un commentaire