math.gamma(alpha) * beta ** alpha
-.. function:: gauss(mu, sigma)
+.. function:: gauss(mu=0.0, sigma=1.0)
Normal distribution, also called the Gaussian distribution. *mu* is the mean,
and *sigma* is the standard deviation. This is slightly faster than
number generator. 2) Put locks around all calls. 3) Use the
slower, but thread-safe :func:`normalvariate` function instead.
+ .. versionchanged:: 3.11
+ *mu* and *sigma* now have default arguments.
+
.. function:: lognormvariate(mu, sigma)
zero.
-.. function:: normalvariate(mu, sigma)
+.. function:: normalvariate(mu=0.0, sigma=1.0)
Normal distribution. *mu* is the mean, and *sigma* is the standard deviation.
+ .. versionchanged:: 3.11
+ *mu* and *sigma* now have default arguments.
+
.. function:: vonmisesvariate(mu, kappa)
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.
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
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()