From b48e38e3fcd8025a7ae91e728d6577abb7eadf2a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 8 May 2024 10:35:05 -0500 Subject: [PATCH] Eliminate local n which shadows a non-local n --- Lib/statistics.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py index 2f897c2d8faf89..c36145fe7f2a79 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -976,12 +976,10 @@ def kde(data, h, kernel='normal', *, cumulative=False): if support is None: def pdf(x): - n = len(data) - return sum(K((x - x_i) / h) for x_i in data) / (n * h) + return sum(K((x - x_i) / h) for x_i in data) / (len(data) * h) def cdf(x): - n = len(data) - return sum(W((x - x_i) / h) for x_i in data) / n + return sum(W((x - x_i) / h) for x_i in data) / len(data) else: