image thumbnail

Weighted Total Least Squares with correlated coefficients

version 1.0.0 (42.5 KB) by Matthias Wurm
Solving linear systems with correlated coefficients using weighted total least squares


Updated 17 Dec 2021

View License

This function solves over-determined linear systems of the form (A+dA)x = (b+db) numerically.
Individual weights for and correlations between the deviations [dA,db] are allowed.
These weights have to be given as a matrix W, which typically is the inverse of a (positive definite) covariance-matrix.
If A is a (m x n) matrix, then b has to be a (m x 1) vector and the weight matrix has to be a (m (n+1) x m (n+1)) matrix.
This is different from the so-called "general total leat squares" method, where only column or row-wise correlations are considered.
Additionally it is allowed to declare individual elements of a [A,b] to be free of errors.
The covariance matrix of the best fitting x-vector is provided.
The code has been optimized to achieve high computational speed.
"lsqnonlin" from the "optimization toolbox" is needed.
For large problems and highest performance A, b, and W should be declared as gpuArrays (which requires the "Parallel Computing Toolbox").
Partially modified code from other authors is required and included:
- "wtls_line" and "wtlsc_line" from Anton
- "multiprod" from de Leva
- "derivest", "hessdiag", "hessian", and "nderivediag" from D'Errico
- "gmtls" and "mtls" from Houtzager
- "gtls" from Rhode
(full references are given in the paper)
Best practice: Use the demo to see some examples and check the paper.

Cite As

Matthias Wurm (2022). Weighted Total Least Squares with correlated coefficients (, MATLAB Central File Exchange. Retrieved .

Wurm, Matthias. “A Universal and Fast Method to Solve Linear Systems with Correlated Coefficients Using Weighted Total Least Squares.” Measurement Science and Technology, vol. 33, no. 1, IOP Publishing, Nov. 2021, p. 015017, doi:10.1088/1361-6501/ac32ec.

View more styles
MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!