Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
47b1fb93
Commit
47b1fb93
authored
Jan 26, 2001
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug 130030: Claim of bad betavariate algorithm.
parent
30da8740
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
Lib/random.py
Lib/random.py
+19
-6
Misc/ACKS
Misc/ACKS
+2
-1
No files found.
Lib/random.py
View file @
47b1fb93
...
...
@@ -461,14 +461,27 @@ class Random:
return
mu
+
z
*
sigma
## -------------------- beta --------------------
## See
## http://sourceforge.net/bugs/?func=detailbug&bug_id=130030&group_id=5470
## for Ivan Frohne's insightful analysis of why the original implementation:
##
## def betavariate(self, alpha, beta):
## # Discrete Event Simulation in C, pp 87-88.
##
## y = self.expovariate(alpha)
## z = self.expovariate(1.0/beta)
## return z/(y+z)
##
## was dead wrong, and how it probably got that way.
def
betavariate
(
self
,
alpha
,
beta
):
# Discrete Event Simulation in C, pp 87-88.
y
=
self
.
expovariate
(
alpha
)
z
=
self
.
expovariate
(
1.0
/
beta
)
return
z
/
(
y
+
z
)
# This version due to Janne Sinkkonen, and matches all the std
# texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution").
y
=
self
.
gammavariate
(
alpha
,
1.
)
if
y
==
0
:
return
0.0
else
:
return
y
/
(
y
+
self
.
gammavariate
(
beta
,
1.
))
## -------------------- Pareto --------------------
...
...
Misc/ACKS
View file @
47b1fb93
...
...
@@ -118,7 +118,7 @@ Sebastian Fernandez
Nils Fischbeck
Doug Fort
Robin Friedrich
Ivan Frohe
Ivan Froh
n
e
Jim Fulton
Geoff Furnish
Tadayoshi Funaba
...
...
@@ -338,6 +338,7 @@ Joel Shprentz
Eric Siegerman
Paul Sijben
Nathan Paul Simons
Janne Sinkkonen
George Sipe
Kragen Sitaker
Rafal Smotrzyk
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment