Skip to content

statistics.NormalDist.overlap returns incorrect coefficient for large finite standard deviations #158758

Description

@augusto-rehfeldt

Bug report

Bug description:

Documented behaviour: NormalDist.overlap documentation: "Compute the overlapping coefficient (OVL) between two normal distributions." The overlapping coefficient is the integral of the minimum of the two probability density functions.

Expected: Approximately 0.6773254311652314, within absolute tolerance 1e-12, without raising.

Actual: 1.0 for NormalDist(0.0, 1e150).overlap(NormalDist(0.0, 2e150)).

import math
from statistics import NormalDist

p = ((0.0, 1e150), (0.0, 2e150))
if not all(math.isfinite(m) and math.isfinite(s) and s > 0 for m, s in p):
    print("REFUTATION REJECTED:", "invalid normal-distribution parameters")
else:
    # Integrate the narrower density outside the crossings, wider inside.
    t = math.sqrt(4 * math.log(2) / 3)
    expected = 1 + math.erf(t / 2) - math.erf(t)
    try:
        actual = NormalDist(*p[0]).overlap(NormalDist(*p[1]))
    except Exception as e:
        print("REFUTATION CONFIRMED:", p, "actual =", repr(e), "expected =", expected)
    else:
        if not math.isfinite(actual) or abs(actual - expected) > 1e-12:
            print("REFUTATION CONFIRMED:", p, "actual =", actual, "expected =", expected)
        else:
            print("REFUTATION REJECTED:", "actual agrees with the independent integral")

Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library statistics:

REFUTATION CONFIRMED: ((0.0, 1e+150), (0.0, 2e+150)) actual = 1.0 expected = 0.6773254311652314

This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/statistics-20261003-124541-c4

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions