Skip to content

Commit

Permalink
Small speed-up for NormalDist.samples (pythonGH-94730)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger authored Jul 11, 2022
1 parent e8e4b55 commit c9118af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ def samples(self, n, *, seed=None):
"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"
Expand Down

0 comments on commit c9118af

Please sign in to comment.