8000 gh-115532: Add kernel density estimation to the statistics module by rhettinger · Pull Request #115863 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115532: Add kernel density estimation to the statistics module #115863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve appearance of generated docstring
  • Loading branch information
rhettinger committed Feb 24, 2024
commit 24e38e2020c35a4da6c6462bcfbff2fe25c1e724
4 changes: 2 additions & 2 deletions Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def kde(data, h, kernel='normal'):
raise TypeError('Data sequence must contain ints or floats')

if h <= 0.0:
raise StatisticsError(f'Bandwidth h must be positive, not {h=}')
raise StatisticsError(f'Bandwidth h must be positive, not {h=!r}')

match kernel:

Expand Down Expand Up @@ -957,7 +957,7 @@ def pdf(x):
supported = sample[i : j]
return sum(K((x - x_i) / h) for x_i in supported) / (n * h)

pdf.__doc__ = f'PDF estimate with the {kernel!r} kernel and bandwidth {h}.'
pdf.__doc__ = f'PDF estimate with {kernel=!r} and {h=!r}'

return pdf

Expand Down
0