summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/random.py4
-rw-r--r--Lib/test/test_random.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 6d7b617..1f3530e 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -538,7 +538,7 @@ class Random(_random.Random):
low, high = high, low
return low + (high - low) * _sqrt(u * c)
- def normalvariate(self, mu, sigma):
+ def normalvariate(self, mu=0.0, sigma=1.0):
"""Normal distribution.
mu is the mean, and sigma is the standard deviation.
@@ -559,7 +559,7 @@ class Random(_random.Random):
break
return mu + z * sigma
- def gauss(self, mu, sigma):
+ def gauss(self, mu=0.0, sigma=1.0):
"""Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 5b066d2..32e7868 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -409,6 +409,10 @@ class TestBasicOps:
self.assertRaises(ValueError, self.gen.randbytes, -1)
self.assertRaises(TypeError, self.gen.randbytes, 1.0)
+ def test_mu_sigma_default_args(self):
+ self.assertIsInstance(self.gen.normalvariate(), float)
+ self.assertIsInstance(self.gen.gauss(), float)
+
try:
random.SystemRandom().random()