Skip to content

mhawarey/lsa-engine

Repository files navigation

LSA Engine — Least Squares Adjustment

License: MIT

A native desktop GUI for geodetic and general least squares adjustment — four estimators, residual plot, and variance-covariance heatmap. Built in Rust with egui.

Screenshots

Input Tab Results Tab
Input Results
Residual Plot VCV Heatmap
Residual Plot VCV Heatmap

About

Estimators

Method Formula Use Case
Unweighted LS x̂ = (AᵀA)⁻¹Aᵀb Equal-precision observations
Weighted LS x̂ = (AᵀWA)⁻¹AᵀWb Different observation precisions
Constrained LS min ‖v‖² s.t. Cx=d Fixed constraints on unknowns
Robust IRLS Iterative Huber reweighting Data with outliers

Problem Type

General Ax = b — you supply the design matrix A, observation vector b, and optionally the weight matrix W and constraint matrix C. Works for any linear adjustment problem: levelling networks, traverse, polynomial fitting, coordinate transformation, sensor fusion, etc.

Outputs

  • Estimated unknowns x̂ with standard deviations σ(x̂)
  • Reference variance σ₀² and σ₀
  • Residuals v = Ax̂ − b with standardised values v/σ₀
  • Colour-coded outlier detection: green |v/σ₀|<2, yellow 2–3, red >3
  • Residual bar chart with hover tooltip
  • VCV heatmap — visual variance-covariance matrix

Math

Unweighted LS:   x̂ = (AᵀA)⁻¹Aᵀb
Weighted LS:     x̂ = (AᵀWA)⁻¹AᵀWb
Constrained LS:  augmented system via Lagrange multipliers
σ₀²:             vᵀWv / r       r = n − u  (degrees of freedom)
Σ_x̂:             σ₀² · (AᵀWA)⁻¹

Robust IRLS — Huber ψ-function:

ψ(t) = t              |t| ≤ k   (Gaussian)
ψ(t) = k · sign(t)    |t| > k   (outlier)
wᵢ   = k·σ̂ / |vᵢ|    for downweighted obs
σ̂    = median(|vᵢ|) / 0.6745   (MAD robust estimate)

Default k = 1.345 → 95% efficiency under normality.

Built-in Examples

Example n u r Notes
Levelling Network 4 3 1 Height differences
Polynomial Fit 5 3 2 Quadratic y = a + bx + cx²
2D Position 5 2 3 Weighted observations
Outlier Demo 7 2 5 One large outlier — use Robust IRLS

Build & Run

# Prerequisites: Rust ≥ 1.75
cargo build --release
cargo run --release
# or double-click run.bat on Windows

Tests:

cargo test
# 9 passed; 0 failed

References

  • Mikhail, E.M. & Ackermann, F. (1976). Observations and Least Squares. IEP.
  • Koch, K.-R. (1999). Parameter Estimation and Hypothesis Testing in Linear Models. Springer.
  • Huber, P.J. (1964). Robust estimation of a location parameter. Ann. Math. Stat. 35(1).
  • Leick, A. (2004). GPS Satellite Surveying, 3rd ed. Wiley.

Author

Dr. Mosab Hawarey

PhD, Geodetic & Photogrammetric Engineering (ITU) | MSc, Geomatics (Purdue) | MBA (Wales) | BSc, MSc (METU)

License

MIT License

About

Least Squares Adjustment Engine - A native desktop GUI for geodetic and general least squares adjustment — four estimators, residual plot, and variance-covariance heatmap. Built in Rust with egui.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors