[Patches] [ python-Patches-529408 ] fix random.gammavariate bug #527139
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 18 Mar 2002 05:08:25 -0800
Patches item #529408, was opened at 2002-03-13 12:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=529408&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: John Machin (sjmachin)
Assigned to: Tim Peters (tim_one)
Summary: fix random.gammavariate bug #527139
Initial Comment:
random.gammavariate() doesn't work for gamma < 0.5
See detailed comment on bug # 527139
----------------------------------------------------------------------
>Comment By: Michael Hudson (mwh)
Date: 2002-03-18 13:08
Message:
Logged In: YES
user_id=6656
I'm afraid this isn't going to make 2.2.1c1.
I'll try to consider it before 2.2.1 final, but I'd want to
be very certain about things before applying it there.
----------------------------------------------------------------------
Comment By: John Machin (sjmachin)
Date: 2002-03-18 13:05
Message:
Logged In: YES
user_id=480138
Attached is test script test_gamma.py. Passing test means:
eye-balling of relative "errors" reveals no nasties for at
least alpha >= 0.1
Note that Python's gammavariate() is not very accurate at
all for alpha < 0.1 approx. However neither are another two
methods that I tried (details in the file). I'll leave it
at that -- evidently alpha < 1.0 is "rare and difficult"
according to Marsaglia & Tsang.
----------------------------------------------------------------------
Comment By: John Machin (sjmachin)
Date: 2002-03-18 12:57
Message:
Logged In: YES
user_id=480138
Patch file random2.dif uploaded.
stdgamma() deprecated as per TP suggestion.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-03-18 05:32
Message:
Logged In: YES
user_id=31435
John, if I were you <wink> I'd leave stdgamma alone, except
for adding this code to its start:
import warnings
warnings.warn("The stdgamma function is deprecated; "
"use gammavariate() instead",
DeprecationWarning)
Then we can remove stdgamma in 2.4. 2.2.1 will probably go
out on Monday night, so it would be nice to get this done
before then. OTOH, I expect there will be a 2.2.2 later,
so not a tragedy if it's not.
----------------------------------------------------------------------
Comment By: John Machin (sjmachin)
Date: 2002-03-17 20:46
Message:
Logged In: YES
user_id=480138
OK; I understand the problems with the patch. Not sure
about the way forward -- shall I prepare a patch that just
fixes gammavariate() and leaves stdgamma() there (with
warning in the comments: deprecated? will be removed in
2.x?)? Do you want it real soon now (for 2.2.1)?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-03-17 19:42
Message:
Logged In: YES
user_id=31435
Michael, this definitely doesn't belong in 2.2.1 as-is,
because it removes a currently-exported name (buggy or not,
sensible or not, somebody may be using random.stdgamma now
and be happy with it).
John, if you're going to remove stdgamma, you need also to
remove its (string) name from the module's __all__ list
(right before the _verify() function).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-03-16 17:38
Message:
Logged In: YES
user_id=31435
Possibly, depending on whether it belongs in 2.3 -- I'm
spread too thin to review it now.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2002-03-16 16:53
Message:
Logged In: YES
user_id=6656
Tim, do you think this should go into 2.2.1?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=529408&group_id=5470