-
Notifications
You must be signed in to change notification settings - Fork 0
Step 3 ‐ Find Best Offset
HRAshton edited this page Oct 18, 2025
·
1 revision
Consolidate multiple candidate offsets into a single robust result.
Given many noisy candidate intervals from correlation, this step selects one representative Interval(start, end) by clustering and robust statistics.
-
Candidate Intervals
- A list of intervals from Step 2 for the same comparison scope.
- Each item provides
startandendoffsets in seconds for each signal (audio file). Some values may be NaN.
-
Configuration Parameters
-
precision_secs— resolution used to decide if values are already “close enough.”
-
- Remove NaN entries from
startandendlists independently. - If a list becomes empty, the result for that side is NaN.
- If all remaining values are within
precision_secs / 2of each other, return their common value (e.g., median).
- Otherwise, cluster the 1-D values using KMeans.
- Determine cluster count k by maximizing the silhouette score over a small k-grid.
- Select candidate clusters with the highest membership (most points).
- If several clusters tie on size, pick the one with the smallest spread (range).
- For the chosen cluster, return the median value.
- Apply Steps 1-4 independently to
startvalues and toendvalues.
- Combine the consolidated
startandendinto a singleInterval(start, end). - If either side is NaN, the interval is considered invalid for subsequent stages.
-
Best Interval
- One
Interval(start, end)that represents the dominant offset among candidates. - Designed to be stable under outliers and multi-modal candidate distributions.
- One
flowchart TD
A[Candidate Intervals] --> B[NaN Filtering]
B --> C[Close-Values Fast Path]
C --> D[KMeans + Silhouette Selection]
D --> E[Median per Cluster]
E --> F[Compose Interval(start, end)]