MCPcopy Index your code
hub / github.com/RustPython/RustPython / overlap_numeric

Method overlap_numeric

Lib/test/test_statistics.py:3127–3138  ·  view source on GitHub ↗

Numerical integration cross-check for overlap()

(X, Y, *, steps=8_192, z=5)

Source from the content-addressed store, hash-verified

3125
3126 # Check against integration of the PDF
3127 def overlap_numeric(X, Y, *, steps=8_192, z=5):
3128 'Numerical integration cross-check for overlap() '
3129 fsum = math.fsum
3130 center = (X.mean + Y.mean) / 2.0
3131 width = z * max(X.stdev, Y.stdev)
3132 start = center - width
3133 dx = 2.0 * width / steps
3134 x_arr = [start + i*dx for i in range(steps)]
3135 xp = list(map(X.pdf, x_arr))
3136 yp = list(map(Y.pdf, x_arr))
3137 total = max(fsum(xp), fsum(yp))
3138 return fsum(map(min, xp, yp)) / total
3139
3140 for X1, X2 in [
3141 # Examples from Imman and Bradley

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
listClass · 0.85
fsumFunction · 0.85

Tested by

no test coverage detected