Skip to content

Commit 95c7788

Browse files
authored
Refactor random number generation logic
Removed unnecessary try-except block for log(0.0) handling.
1 parent 9d6eaf7 commit 95c7788

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

Lib/random.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,9 @@ def binomialvariate(self, n=1, p=0.5):
836836
if not c:
837837
return x
838838
while True:
839-
try:
840839
y += _floor(_log2(random()) / c) + 1
841-
except ValueError:
842-
# Handle rare case of log(0.0)
843-
continue
844840
if y > n:
845-
return x
841+
return x
846842
x += 1
847843

848844
# BTRS: Transformed rejection with squeeze method by Wolfgang Hörmann

0 commit comments

Comments
 (0)