Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger committed Apr 30, 2024
1 parent d71ca9d commit ee43ed7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,15 +1788,15 @@ def kde_random(data, h, kernel='normal', *, seed=None):
if h <= 0.0:
raise StatisticsError(f'Bandwidth h must be positive, not {h=!r}')

prng = _random.Random(seed)
random = prng.random
choice = prng.choice

try:
kernel_invcdf = _kernel_invcdfs[kernel]
except KeyError:
raise StatisticsError(f'Unknown kernel name: {kernel!r}')

prng = _random.Random(seed)
random = prng.random
choice = prng.choice

def rand():
return choice(data) + h * kernel_invcdf(random())

Expand Down

0 comments on commit ee43ed7

Please sign in to comment.