Apex › Storage & databases

Fitting a line through 50% outliers (RANSAC)

Least-squares minimizes error over every point, so a few outliers drag the fit off. RANSAC ignores them: repeatedly pick 2 random points, fit a line, count inliers within a threshold, keep the line with the most, refit on those. Produce it: drag the outlier slider up and least-squares’ slope drifts off (0.43 → 0.11) while RANSAC holds at ~0.60 even past 80% garbage — though the tries it needs explode (5 → 203). Then break it: plant a decoy line with more points, and RANSAC locks onto the DECOY (slope −0.32), ignoring the true line — it finds the biggest consensus, not the truth.

More in Storage & databases