feat: RandUtil nextBool false 엔트로피 절약

This commit is contained in:
2022-05-17 23:10:52 +09:00
parent 8595f96a86
commit 9efe7ba171
2 changed files with 7 additions and 1 deletions
+3
View File
@@ -35,6 +35,9 @@ export class RandUtil {
if (prob === 0.5){ if (prob === 0.5){
return this.nextBit(); return this.nextBit();
} }
if (prob <= 0){
return false;
}
return this.nextFloat1() < prob; return this.nextFloat1() < prob;
} }
+4 -1
View File
@@ -42,9 +42,12 @@ class RandUtil
if ($prob >= 1) { if ($prob >= 1) {
return true; return true;
} }
if($prob === 0.5){ if ($prob === 0.5){
return $this->nextBit(); return $this->nextBit();
} }
if ($prob <= 0){
return false;
}
return $this->nextFloat1() < $prob; return $this->nextFloat1() < $prob;
} }