MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / overlap

Method overlap

tools/python-3.11.9-amd64/Lib/statistics.py:1239–1271  ·  view source on GitHub ↗

Compute the overlapping coefficient (OVL) between two normal distributions. Measures the agreement between two normal probability distributions. Returns a value between 0.0 and 1.0 giving the overlapping area in the two underlying probability density functions.

(self, other)

Source from the content-addressed store, hash-verified

1237 return [self.inv_cdf(i / n) for i in range(1, n)]
1238
1239 def overlap(self, other):
1240 """Compute the overlapping coefficient (OVL) between two normal distributions.
1241
1242 Measures the agreement between two normal probability distributions.
1243 Returns a value between 0.0 and 1.0 giving the overlapping area in
1244 the two underlying probability density functions.
1245
1246 >>> N1 = NormalDist(2.4, 1.6)
1247 >>> N2 = NormalDist(3.2, 2.0)
1248 >>> N1.overlap(N2)
1249 0.8035050657330205
1250 """
1251 # See: "The overlapping coefficient as a measure of agreement between
1252 # probability distributions and point estimation of the overlap of two
1253 # normal densities" -- Henry F. Inman and Edwin L. Bradley Jr
1254 # http://dx.doi.org/10.1080/03610928908830127
1255 if not isinstance(other, NormalDist):
1256 raise TypeError('Expected another NormalDist instance')
1257 X, Y = self, other
1258 if (Y._sigma, Y._mu) < (X._sigma, X._mu): # sort to assure commutativity
1259 X, Y = Y, X
1260 X_var, Y_var = X.variance, Y.variance
1261 if not X_var or not Y_var:
1262 raise StatisticsError('overlap() not defined when sigma is zero')
1263 dv = Y_var - X_var
1264 dm = fabs(Y._mu - X._mu)
1265 if not dv:
1266 return 1.0 - erf(dm / (2.0 * X._sigma * _SQRT2))
1267 a = X._mu * Y_var - Y._mu * X_var
1268 b = X._sigma * Y._sigma * sqrt(dm * dm + dv * log(Y_var / X_var))
1269 x1 = (a + b) / dv
1270 x2 = (a - b) / dv
1271 return 1.0 - (fabs(Y.cdf(x1) - X.cdf(x1)) + fabs(Y.cdf(x2) - X.cdf(x2)))
1272
1273 def zscore(self, x):
1274 """Compute the Standard Score. (x - mean) / stdev

Callers

nothing calls this directly

Calls 3

StatisticsErrorClass · 0.85
logFunction · 0.85
cdfMethod · 0.80

Tested by

no test coverage detected