mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-09-10 19:15:25 +02:00
33 lines
1.2 KiB
TeX
33 lines
1.2 KiB
TeX
\newpage
|
|
\subsection{Non-Linear Least Squares}
|
|
Find $\vec{x}^* = \text{argmax}\; \P(\vec{x} | \vec{z}) = \argmin{}(-\log(\P(\vec{x}|\vec{z})))$
|
|
|
|
\bi{Gauss-Newton} Need func $F$ and its Jacobian (or derivative) $DF$
|
|
\rmvspace[0.3]
|
|
% TODO: Error propagation laws
|
|
{\small
|
|
\begin{minted}[
|
|
breaklines,
|
|
breakindentnchars=2,
|
|
]{python}
|
|
def gauss_newton(x: np.ndarray, F, DF, tol=1e-6):
|
|
s = np.linalg.lstsq(DF(x), F(x))[0] # least sq.
|
|
x = x-s; k = 1
|
|
while np.linalg.norm(s) > tol * np.linalg.norm(x):
|
|
s = np.linalg.lstsq(DF(x), F(x))[0]
|
|
x = x-s; k += 1 # k optional for max iter
|
|
return x, k
|
|
\end{minted}
|
|
}
|
|
\rmvspace[0.4]
|
|
|
|
\bi{Levenberg-Marquardt}
|
|
\bi{(1)} Pick start point $\overline{\vec{x}}^0$ and start param $\lambda^0 = \max \text{diag}(\mat{A})$ and $v$ (e.g. $v = 2$).;
|
|
\bi{(2)} Modified GN sys: $\mat{A} + \lambda \text{diag}(\mat{A})) \Delta \vec{x} = \vec{b}$;
|
|
\bi{(3)} Solve for $\Delta \vec{x}$;
|
|
\bi{(4)} Update: $\overline{\vec{x}}^{k + 1} = \overline{\vec{x}}^k + \Delta \vec{x}$ (if cost reduced),
|
|
else: $\overline{\vec{x}}^{k + 1} = \overline{\vec{x}}^k$, $\lambda^{k + 1} = \lambda^k v$, go to step 3;
|
|
\bi{(5)} Check convergence, else go to step 2
|
|
|
|
\bi{Robust Cost Functions} Account for outliers, by mod. err. terms
|