Skip to main content
← Lab

keoghfloor

confirmedupstream bugPython/C · dtaidistanceSystems & data structuresJuly 25, 2026

the question

Does dtaidistance's C `lb_keogh` seed its upper-envelope accumulator correctly for negative-valued windows?

what came out

dtaidistance's C `lb_keogh` seeds the upper-envelope accumulator at `ui = 0` instead of `-INFINITY` (its lower sibling correctly uses `li = INFINITY`). On all-negative windows the envelope clamps up to zero, so `use_c=True` returns 0.0 where pure Python gives the tight 3.4641. Windowed standard-normal input undercounts up to 100% of pairs. Fix: `ui = -INFINITY`.

method & receipts

  • Result: confirmed
  • Reproducible one script re-runs the whole thing from scratch.
  • Tested — a correctness/benchmark suite ships alongside the code.

→ read the code and re-run it

github.com/v-code01/keoghfloor