[Python-checkins] Update nonstandard variable names (GH-26540) (GH-26546)
rhettinger
webhook-mailer at python.org
Fri Jun 4 22:38:42 EDT 2021
https://github.com/python/cpython/commit/4642caf232a3f01468e76f19cd0c88175e10ee28
commit: 4642caf232a3f01468e76f19cd0c88175e10ee28
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2021-06-04T19:38:30-07:00
summary:
Update nonstandard variable names (GH-26540) (GH-26546)
files:
M Lib/statistics.py
diff --git a/Lib/statistics.py b/Lib/statistics.py
index ceb8af81b0d3d..268cc71a0952b 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -913,10 +913,10 @@ def correlation(x, y, /):
xbar = fsum(x) / n
ybar = fsum(y) / n
sxy = fsum((xi - xbar) * (yi - ybar) for xi, yi in zip(x, y))
- s2x = fsum((xi - xbar) ** 2.0 for xi in x)
- s2y = fsum((yi - ybar) ** 2.0 for yi in y)
+ sxx = fsum((xi - xbar) ** 2.0 for xi in x)
+ syy = fsum((yi - ybar) ** 2.0 for yi in y)
try:
- return sxy / sqrt(s2x * s2y)
+ return sxy / sqrt(sxx * syy)
except ZeroDivisionError:
raise StatisticsError('at least one of the inputs is constant')
@@ -957,9 +957,9 @@ def linear_regression(x, y, /):
xbar = fsum(x) / n
ybar = fsum(y) / n
sxy = fsum((xi - xbar) * (yi - ybar) for xi, yi in zip(x, y))
- s2x = fsum((xi - xbar) ** 2.0 for xi in x)
+ sxx = fsum((xi - xbar) ** 2.0 for xi in x)
try:
- slope = sxy / s2x # equivalent to: covariance(x, y) / variance(x)
+ slope = sxy / sxx # equivalent to: covariance(x, y) / variance(x)
except ZeroDivisionError:
raise StatisticsError('x is constant')
intercept = ybar - slope * xbar
More information about the Python-checkins
mailing list