Skip to content

Conversation

@flinder
Copy link
Contributor

@flinder flinder commented Jan 22, 2026

Summary:

  • Remove the function kuiper_distribution and replace with ecce for usage with normalization_method=None and ecce_sigma for usage with normalization_method="kuiper_standard_deviation"

  • refactor all internal and external callsites to use the new API

Differential Revision: D91235674

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 22, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 22, 2026

@flinder has exported this pull request. If you are a Meta employee, you can view the originating Diff in D91235674.

@flinder flinder force-pushed the export-D91235674 branch 2 times, most recently from 6c36a86 to 822aac8 Compare January 23, 2026 09:51
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 23, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 23, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
@flinder flinder force-pushed the export-D91235674 branch 2 times, most recently from 0509e1c to 1f813b1 Compare January 26, 2026 07:54
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
…lue (facebookincubator#160)

Summary:

Introduces a cleaner public API for Expected Cumulative Calibration Error (ECCE) metrics. The new ecce(), ecce_sigma(), and ecce_pvalue() functions provide simplified interfaces to the existing kuiper calibration functionality, making the API more intuitive for users who want to compute calibration errors without needing to understand the underlying Kuiper test implementation details.

Deprecation of old versions of the functions will come in follow up diffs.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: TaXxER

Differential Revision: D91235672
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
flinder added a commit to flinder/MCGrad-1 that referenced this pull request Jan 26, 2026
Summary:

Removes the public `kuiper_calibration` function and updates internal callers to use the new ECCE API or lower-level functions directly.

### Changes

**Removed:**
- `kuiper_calibration()` - wrapper function that computed Kuiper calibration distance

**Refactored:**
- `kuiper_test()` - now calls `ecce_sigma()` directly instead of `kuiper_calibration(..., normalization_method="kuiper_standard_deviation")` [Note: this function will be removed in a future commit]
- `ecce()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`
- `ecce_sigma()` - now calls `kuiper_calibration_per_segment(...).item()` directly instead of going through `kuiper_calibration()`

### Rationale
This is part of a cleanup series migrating from the legacy "kuiper" naming to the cleaner "ECCE" (Expected Cumulative Calibration Error) API. The `kuiper_calibration` function was just a thin wrapper that called `kuiper_calibration_per_segment().item()`, so callers now use that pattern directly.


-------------------------------------
Target API design
-------------------------------------

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│                              ECCE API ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────────┤
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                         PUBLIC API (User-Facing)                          ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   ┌─────────────┐    ┌──────────────┐    ┌──────────────────────────┐    ║  │
│  ║   │   ecce()    │    │ ecce_sigma() │    │      ecce_pvalue()       │    ║  │
│  ║   │             │    │              │    │                          │    ║  │
│  ║   │ Unnormalized│    │  Normalized  │    │   P-value for            │    ║  │
│  ║   │ calibration │───▶│  by std dev  │───▶│   calibration test       │    ║  │
│  ║   │ error       │    │  (sigma)     │    │                          │    ║  │
│  ║   └──────┬──────┘    └──────┬───────┘    └────────────┬─────────────┘    ║  │
│  ║          │                  │                         │                  ║  │
│  ╚══════════╪══════════════════╪═════════════════════════╪══════════════════╝  │
│             │                  │                         │                     │
│             │                  │                         ▼                     │
│             │                  │           ┌──────────────────────────┐        │
│             │                  │           │  ecce_pvalue_from_sigma()│        │
│             │                  │           │  (public helper)         │        │
│             │                  │           └────────────┬─────────────┘        │
│             │                  │                        │                      │
│  ┌──────────┴──────────────────┴────────────────────────┴───────────────────┐  │
│  │                         PRIVATE HELPERS                                  │  │
│  ├──────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                          │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │ _calculate_cumulative_         │    │     _ecce_cdf()             │  │  │
│  │   │        differences()           │    │                             │  │  │
│  │   │                                │    │  CDF for Brownian motion    │  │  │
│  │   │  Core computation of weighted  │    │  range (for p-value calc)   │  │  │
│  │   │  cumulative differences        │    │                             │  │  │
│  │   └───────────────┬────────────────┘    └─────────────────────────────┘  │  │
│  │                   │                                                      │  │
│  │                   ▼                                                      │  │
│  │   ┌────────────────────────────────┐    ┌─────────────────────────────┐  │  │
│  │   │    _ecce_per_segment()         │    │ _ecce_standard_deviation()  │  │  │
│  │   │                                │    │                             │  │  │
│  │   │  Vectorized ECCE computation   │    │  Wrapper → calls per_segment│  │  │
│  │   │  for multiple segments         │    │  version with .item()       │  │  │
│  │   └────────────────────────────────┘    └──────────────┬──────────────┘  │  │
│  │                                                        │                 │  │
│  │                                                        ▼                 │  │
│  │                                         ┌─────────────────────────────┐  │  │
│  │                                         │ _ecce_standard_deviation_   │  │  │
│  │                                         │        per_segment()        │  │  │
│  │                                         │                             │  │  │
│  │                                         │  Variance-based std dev     │  │  │
│  │                                         │  for multiple segments      │  │  │
│  │                                         └─────────────────────────────┘  │  │
│  │                                                                          │  │
│  └──────────────────────────────────────────────────────────────────────────┘  │
│                                                                                 │
│  ╔═══════════════════════════════════════════════════════════════════════════╗  │
│  ║                       MulticalibrationError Class                         ║  │
│  ╠═══════════════════════════════════════════════════════════════════════════╣  │
│  ║                                                                           ║  │
│  ║   Computes calibration metrics across multiple data segments              ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Cached Properties                              │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_ecces_absolute ──────────▶ _ecce_per_segment()             │ ║  │
│  ║   │  (ECCE per segment)                                                 │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_sigmas ──────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (std dev per segment)                  per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  sigma_0 ─────────────────────────▶ _ecce_standard_deviation_       │ ║  │
│  ║   │  (global std dev)                       per_segment()               │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  p_value ─────────────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (min p-value across segments)                                      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  segment_p_values ────────────────▶ ecce_pvalue_from_sigma()        │ ║  │
│  ║   │  (p-value per segment)                  (vectorized)                │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ║   ┌─────────────────────────────────────────────────────────────────────┐ ║  │
│  ║   │                      Derived Metrics                                │ ║  │
│  ║   ├─────────────────────────────────────────────────────────────────────┤ ║  │
│  ║   │                                                                     │ ║  │
│  ║   │  mce               = max(segment_ecces_absolute)                    │ ║  │
│  ║   │  mce_sigma_scale   = max(segment_ecces_absolute / segment_sigmas)   │ ║  │
│  ║   │  mce_relative      = mce / ecce_0  (normalized by global ECCE)      │ ║  │
│  ║   │                                                                     │ ║  │
│  ║   └─────────────────────────────────────────────────────────────────────┘ ║  │
│  ║                                                                           ║  │
│  ╚═══════════════════════════════════════════════════════════════════════════╝  │
│                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────┘
```

Reviewed By: Lorenzo-Perini

Differential Revision: D91235674
@meta-codesync meta-codesync bot closed this in cdfeef6 Jan 26, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 26, 2026

This pull request has been merged in cdfeef6.

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants