feat: nextBool에서 0.5인 경우 엔트로피 절약

This commit is contained in:
2022-05-17 23:08:03 +09:00
parent 485d696e85
commit da3fb2c094
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -32,6 +32,9 @@ export class RandUtil {
if (prob >= 1) { if (prob >= 1) {
return true; return true;
} }
if (prob === 0.5){
return this.nextBit();
}
return this.nextFloat1() < prob; return this.nextFloat1() < prob;
} }
+3
View File
@@ -42,6 +42,9 @@ class RandUtil
if ($prob >= 1) { if ($prob >= 1) {
return true; return true;
} }
if($prob === 0.5){
return $this->nextBit();
}
return $this->nextFloat1() < $prob; return $this->nextFloat1() < $prob;
} }