Scoring

The scale-free marginal score and its sort-and-sweep, on VisualGeometryToolkitCore's scoring contract, and the loss-width ("threshold-based") scorings it is compared against.

Problems and the scoring contract

A problem is scored through VisualGeometryToolkitCore's constraint-problem protocol: it subtypes AbstractConstraintProblem and implements data_size, codimension, minimal_sample_size and constraint_with_jacobians; predictive scoring additionally needs solver_covariance, declared by provides_solver_covariance. A scorer implements VisualGeometryToolkitCore's scoring contract (scoring_workspace, score!, inlier_count, consensus_order, …), and the scale prior IGPrior (Jeffreys: JeffreysPrior()), the Student-t + uniform mixture toolkit and the Gaussian-uniform boundary (GauInlier, decision_boundary) are VisualGeometryToolkitCore's too. The concrete problems (homography, fundamental and essential matrix, …) live in VisualGeometryToolkitEstimation.

The scale-free marginal score

The Student-t + uniform marginal score itself is VisualGeometryToolkitCore's (moved there on 2026-11-11): StudentTUniformScoring carries the configuration (outlier model, model degrees of freedom, the scale and label priors, both required: the stack's defaults are VisualGeometryToolkitEstimation's [scoring.student_t_uniform], read by scoring_from_toml), ScoringWorkspace the scratch buffers of the sort-and-sweep, and StudentTUniformScoring{Predictive} scores a model with its solver covariance. This package extends it by dispatch: its grids (grid_evaluate, select_on_grid!) and the outlier models below.

Outlier models that estimate the support

Core's estimated-support sweep scores these through their methods of its hooks (outlier_cost, scored_outlier_halfwidth, outlier_context!); model-certain, codimension 1.

RANSACScoringDoneRight.TailRules — Type
TailRules(; pot_threshold_quantile, min_excess, finite_shape_limit)   # defaults: configs/default.toml [tail_rules]

The rules of the generalized Pareto tail fit.

The peaks-over-threshold (POT) rules both extreme-value outlier models share (Coles 2001, §4.3; Hosking & Wallis 1987): the generalized Pareto law is fitted by probability-weighted moments to the excesses over the POT threshold u, and pot_threshold_quantile is the quantile level of the complement's residuals at which the POT threshold u is set. Fewer than min_excess excesses, or a shape at or above finite_shape_limit (no finite endpoint), fall back to the largest residual of the complement; an endpoint below it is raised to it. The defaults (0.9, 5, -1e-3) are configs/default.toml's [tail_rules]. The retired keyword threshold_quantile is an ArgumentError naming pot_threshold_quantile.

References: S. Coles, An Introduction to Statistical Modeling of Extreme Values, Springer, 2001, §4.3; J. R. M. Hosking and J. R. Wallis, "Parameter and quantile estimation for the generalized Pareto distribution", Technometrics 29(3), 1987.

source
RANSACScoringDoneRight.ExtremeValueHalfwidth — Type
ExtremeValueHalfwidth(; tail rules...)

A uniform outlier model whose half-width is the fitted tail's endpoint.

The uniform outlier density at a half-width estimated from each partition's complement: the endpoint u - ω/ξ of the generalized Pareto law the TailRules (its keywords) fit to the complement's upper tail.

source
RANSACScoringDoneRight.GeneralizedParetoOutliers — Type
GeneralizedParetoOutliers(; fit_per = :prefix, tail rules...)

An outlier model whose density is the fitted generalized Pareto law.

The fitted generalized Pareto law itself as the outlier density: the law of the TailRules fit, carried down to zero by threshold stability, with scale |ξ|·a at zero and endpoint a — the uniform density at ξ = -1, and the uniform one where there is no finite-endpoint fit. fit_per = :prefix refits the tail for every partition (exact, Θ(N²) per hypothesis); :hypothesis fits it once to the upper tail of all residuals (Θ(N), without the prefix-optimality guarantee).

source
RANSACScoringDoneRight.OutlierTerm — Type
OutlierTerm(cost)

An outlier model given by the caller's cost function.

A caller's outlier term, for research baselines that are not one of the models above (block statistics of the complement): cost(k, z) is the complement's -log density for the partition of the k smallest residuals, z the sorted absolute residuals.

source
RANSACScoringDoneRight.tail_fit — Function
tail_fit(rules, z) -> (; outlier_halfwidth, fitted_endpoint, shape)

The tail fit of rules to the sorted values z.

The peaks-over-threshold fit of rules (a TailRules or an extreme-value outlier model) to the sorted values z: outlier_halfwidth is the uniform half-width (the fitted endpoint, raised to the largest value); fitted_endpoint is -Inf and shape NaN wherever the rules fall back (too few excesses, or no finite-endpoint fit). The sweep fits every prefix's complement the same way, in O(log n) each, from suffix sums it builds once.

source
RANSACScoringDoneRight.gpd_pwm_fit — Function
gpd_pwm_fit(n, sum_excess, sum_rank_excess) -> (shape, scale)

The generalized Pareto shape and scale of n excesses, from two sums.

The probability-weighted-moment fit of a generalized Pareto law G(y) = 1 - (1 + shape·y/scale)^(-1/shape) to n excesses, from their sum and their rank-weighted sum Σ_j j·y_(j) (ascending ranks), with the plotting positions (j - 0.35)/n (Hosking & Wallis 1987; Hosking's k is -shape). Taking the sums rather than the excesses lets the sweep fit every prefix's tail in O(1) from prefix sums.

source
gpd_pwm_fit(excess) -> (shape, scale)

The same fit from the excesses themselves (any order).

source
RANSACScoringDoneRight.gpd_support — Function
gpd_support(fit, z, lo, hi) -> endpoint

The support endpoint of the fitted generalized Pareto density.

The endpoint the generalized Pareto density scores with: the fitted endpoint where it lies beyond every value (for shape > -1 the density vanishes at the endpoint, so the largest value cannot sit on it), else the largest value plus the mean spacing of z[lo:hi] (positive unless every value ties) — equivariant under a change of units.

source
RANSACScoringDoneRight.gpd_outlier_cost — Function
gpd_outlier_cost(z, endpoint, shape) -> Float64

The outlier cost of one residual under the generalized Pareto density.

-log p(r) for one signed scalar residual of absolute value z under the generalized Pareto outlier density of endpoint endpoint and shape shape (GeneralizedPareto(0, σ, shape) with σ = |shape|·endpoint, halved for the sign): log 2 + log σ + (1 + 1/shape)·log(1 - z/endpoint); the uniform log(2·endpoint) where shape is not a finite-endpoint fit.

source

Loss-width scorings

The baselines of the paper (RANSAC, MSAC, GaU/MLESAC, MAGSAC++) and three robust costs, each a type carrying its codimension and scored through one per-residual scalar, VisualGeometryToolkitCore's residual_quality. Each has VisualGeometryToolkitCore's two forms of RansacScoring/MsacScoring: width-free (F(dg), the grid family) and at a loss width (F(dg; threshold = w), or with_width(F(dg), LossWidth(w))), which selects by score!. RANSAC and MSAC are VisualGeometryToolkitCore's baseline scorers; this package adds their grid methods.

RANSACScoringDoneRight.LossWidthScoring — Type
LossWidthScoring{DG}

The loss-width-parameterised scorings of both branches at codimension DG — the paper's "threshold-based family". A Union, not a supertype: "takes a loss width" cuts across the mixture branch and LossCostScoring, so it cannot be a supertype of both without implying a mixture underneath the losses.

This is the type the loss-width sweep entry points accept. Widening them to AbstractScoring would readmit StudentTUniformScoring, which has no loss width and would fail several frames down inside GPU staging instead of at the call site.

source
RANSACScoringDoneRight.MlesacScoring — Type
MlesacScoring{DG, T}

MLESAC (GaU) at codimension DG: the Gaussian-uniform log-density at a fixed scale, normalised to 1 at d = 0 (see residual_quality). Tag "mlesac" (ALL_SCORING_TAGS). MlesacScoring(), MlesacScoring(dg), MlesacScoring(problem): the width-free grid family; MlesacScoring(dg; threshold = w): the scorer at loss width w.

source
RANSACScoringDoneRight.loss_width_scoring — Function
loss_width_scoring(tag) -> LossWidthScoring
loss_width_scoring(tag, dg::Integer) -> LossWidthScoring
loss_width_scoring(tag, problem) -> LossWidthScoring
loss_width_scoring(tag, ::Type{<:AbstractConstraintProblem}) -> LossWidthScoring

The width-free LossWidthScoring family a tag of ALL_SCORING_TAGS names, at a codimension: "ransac", "msac", "mlesac", "magsac", "welsch_cost", "smooth_tls" or "geman". A retired tag ("gau") is an ArgumentError naming its successor, and a tag of a family that takes no loss width ("student_t_uniform", "sim_fit_pp") is refused. The codimension is dg, or codimension(problem); bare, it is 1.

Supply the codimension whenever the problem has one other than 1: the tag vocabulary must not be a back door that silently re-defaults DG.

source
RANSACScoringDoneRight.ALL_SCORING_TAGS — Constant
ALL_SCORING_TAGS

The scoring families' TagRegistry: VisualGeometryToolkitCore's SCORING_TAGS ("ransac", "msac", "student_t_uniform", VisualGeometryToolkitCore's StudentTUniformScoring) merged with this package's — "mlesac", "magsac", "welsch_cost", "smooth_tls", "geman" (the loss-width families) and "sim_fit_pp" (SimFitPP, VisualGeometryToolkitEstimation's SIMFIT++). The retired tags "gau", "welsch" and "simfitpp" name their successors. loss_width_scoring and every config loader read it; tag_of(ALL_SCORING_TAGS, x) is the writer side. It holds Core's SCORING_TAGS and is named apart from it: Core owns that name.

source