[Python-checkins] Simplify overlap() formula for case where variances are equal (GH-12323)

Miss Islington (bot) webhook-mailer at python.org
Thu Mar 14 05:25:31 EDT 2019


https://github.com/python/cpython/commit/41f0b78cbf204649bbae71662a115425c58f048d
commit: 41f0b78cbf204649bbae71662a115425c58f048d
branch: master
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019年03月14日T02:25:26-07:00
summary:
Simplify overlap() formula for case where variances are equal (GH-12323)
files:
M Lib/statistics.py
diff --git a/Lib/statistics.py b/Lib/statistics.py
index 97f154373dc0..8d79eed6b1aa 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -773,7 +773,7 @@ def overlap(self, other):
 dv = Y_var - X_var
 dm = fabs(Y.mu - X.mu)
 if not dv:
- return 2.0 * NormalDist(dm, 2.0 * X.sigma).cdf(0)
+ return 1.0 - erf(dm / (2.0 * X.sigma * sqrt(2.0)))
 a = X.mu * Y_var - Y.mu * X_var
 b = X.sigma * Y.sigma * sqrt(dm**2.0 + dv * log(Y_var / X_var))
 x1 = (a + b) / dv


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /