[Python-bugs-list] [ python-Bugs-506647 ] random.cunifvariate() incorrect?
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 21 Jan 2002 13:20:01 -0800
Bugs item #506647, was opened at 2002-01-21 13:19
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=506647&group_id=5470
Category: Extension Modules
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Maciej Kalisiak (abcdefghijklmno)
Assigned to: Nobody/Anonymous (nobody)
Summary: random.cunifvariate() incorrect?
Initial Comment:
random.cunifvariate() currently is defined as:
return (mean + arc * (self.random() - 0.5)) % _pi
First of all, this returns values in the range [0, pi)
due to the modulus, which really makes it a
semi-circular distribution, not circular (but I'm not a
mathie, so perhaps I'm wrong).
I think the normalizing step ("% _pi", or whatever this
gets changed to) should probably be mentioned in the
documentation for this function; it caught me by
surprise, and I expect it will catch some others too.
With this defintion, the function returns a random
value in the range [mean-arc/2, mean+arc/2). The docs
say that arc, like mean, can only be in the range
[0,pi]. This would imply that one cannot get values in
the other half of the circle, i.e. [pi, 2*pi). Since
there doesn't seem to be anything stopping the caller
from using an arc in [0,2*pi], perhaps the
documentation should be updated?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=506647&group_id=5470