feat: RandUtil nextBool false 엔트로피 절약
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user