Small speed-up for NormalDist.samples (GH-94730)

This commit is contained in:
Raymond Hettinger 2022-07-10 22:34:53 -05:00 committed by GitHub
parent e8e4b550f5
commit c9118afd04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1193,7 +1193,7 @@ class NormalDist:
"Generate *n* samples for a given mean and standard deviation."
gauss = random.gauss if seed is None else random.Random(seed).gauss
mu, sigma = self._mu, self._sigma
return [gauss(mu, sigma) for i in range(n)]
return [gauss(mu, sigma) for _ in repeat(None, n)]
def pdf(self, x):
"Probability density function. P(x <= X < x+dx) / dx"