Numerical integration cross-check for overlap()
(X, Y, *, steps=8_192, z=5)
| 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 |