Skip to content

Use absolute relative error for centroid convergence check#2

Open
uewik wants to merge 4 commits intoghimiresunil:mainfrom
uewik:main
Open

Use absolute relative error for centroid convergence check#2
uewik wants to merge 4 commits intoghimiresunil:mainfrom
uewik:main

Conversation

@uewik
Copy link
Copy Markdown

@uewik uewik commented Jan 14, 2026

The current convergence logic uses a raw sum of percentage changes to determine if the centroids have settled. Because the differences (curr - prev) can be negative, movements in opposite directions across different axes could mathematically cancel each other out (e.g., +5% move on X and -5% move on Y results in a sum of 0). This leads to "false convergence," where the algorithm stops prematurely even though the centroids are still moving.

Changes:

  • Wrapped the centroid delta calculation in np.abs() to ensure all movement contributes positively to the tolerance check.

uewik added 4 commits October 27, 2025 16:22
The current convergence logic uses a raw sum of percentage changes to determine if the centroids have settled. Because the differences (curr - prev) can be negative, movements in opposite directions across different axes could mathematically cancel each other out (e.g., +5% move on X and -5% move on Y results in a sum of 0). This leads to "false convergence," where the algorithm stops prematurely even though the centroids are still moving.

Changes:
- Wrapped the centroid delta calculation in `np.abs()` to ensure all 
  movement contributes positively to the tolerance check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant