diff Lib/random.py @ 82129:6a3d18cede49 2.7

Issue #17149: Fix random.vonmisesvariate to always return results in [0, 2*math.pi].
author Mark Dickinson <dickinsm@gmail.com>
date Sun, 10 Feb 2013 14:13:40 +0000
parents 4970fa3c4a0b
children 0f9113e1b541
line wrap: on
line diff
--- a/Lib/random.py	Sun Feb 10 14:26:08 2013 +0200
+++ b/Lib/random.py	Sun Feb 10 14:13:40 2013 +0000
@@ -475,9 +475,9 @@
 
         u3 = random()
         if u3 > 0.5:
-            theta = (mu % TWOPI) + _acos(f)
+            theta = (mu + _acos(f)) % TWOPI
         else:
-            theta = (mu % TWOPI) - _acos(f)
+            theta = (mu - _acos(f)) % TWOPI
 
         return theta