This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/hf/iv_sweep

Sweeping point strategies against a guaranteed enclosure

The sweep drivers of lib/hf/sweep compare strategies with each other: the consensus is the elementwise median, and the member farthest from it is blamed. That has two blind spots. With two members the median cannot say which one is wrong. And agreement is not correctness: members that share a mistake agree on it.

sweep_iv3 adds a second registry of interval members, which return enclosures that are guaranteed to contain the exact result (lib/hf/iv_ints). Then:

  • the interval members must overlap entry by entry; the exact value is in their common part, the enclosure;
  • every point member's every compared entry must lie inside the enclosure. A point value outside it is wrong by at least its distance from it, whatever the other members say;
  • the median check of lib/hf/sweep still runs, with its tolerance.

The report is the one of lib/hf/sweep, [strategy, flat index, worst, nstrat, lo, hi], and this driver fills the two slots reserved for it: lo and hi are the enclosure at the reported flat index. Blame goes, in this order, to

  1. an interval member whose enclosure misses the others' at some entry: the strategy is reported as nstrat + j for interval member j, and worst is the gap relative to 1 + |median|;
  2. the point member farthest outside the enclosure, with worst its distance relative to 1 + |median|;
  3. otherwise the median's blame, as in sw_table_median.

The verdict is 1 only when the enclosures overlap everywhere, every point value is inside, and the median deviation is below tol.

Point members have the signature (Arr, Arr, Arr) -> Arr and return N entries. Interval members have the same signature and return 2N entries, entry k at [2k, 2k+1] (a [..., 2] array flattened). Only the first ncmp entries are compared. release_mode() runs point member 0 alone.

Used with import hf.iv_sweep.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 45–352