Skip to content

Fix bounded Tikhonov solver, regularization issues, and improve validation - #16

Open
NilsWildt wants to merge 17 commits into
mdpetters:masterfrom
NilsWildt:master
Open

Fix bounded Tikhonov solver, regularization issues, and improve validation#16
NilsWildt wants to merge 17 commits into
mdpetters:masterfrom
NilsWildt:master

Conversation

@NilsWildt

Copy link
Copy Markdown

Me + LLM updated the repo, fixed jetls found type instabilities, added tests, made sure we would pass all tests, fixed bugs, changed Plotting to CairoMakie.jl.

Nils Wildt added 17 commits August 25, 2026 08:57
The bounded solver fed a scalar objective and gradient into
LeastSquaresOptim's residual/Jacobian interface, so Dogleg converged
to a point worse than its starting value. Replace it with Optim.Fminbox
on the correct objective and update the affected regression values.
The constructor passed L⁺ₐ and L⁺ in the wrong order, so Ψ.L⁺ held the
A-weighted generalized inverse and Ψ.L⁺ₐ held the plain pseudoinverse.
It worked only because to_general_form happened to read Ψ.L⁺.
Negative Γ order recursed infinitely; degenerate L dimensions were
silently accepted. Throw clear ArgumentError/DimensionMismatch instead.
Drop the unused x̄ argument and the scalar [1]/broadcast no-ops.
Use p.x instead of getfield and throw ArgumentError on unknown methods.
Cover input validation (Γ, setupRegularizationProblem), the L⁺/L⁺ₐ
field values, bounded-solve correctness, the designmatrix shortcut,
the non-bounds λ search, and type stability. Raises coverage from
97.0% to 98.5%.
ĀĀ + λ²I is positive definite for λ > 0, so the cholesky fast path
always succeeds and the fallback to \ was dead code. Use cholesky!
directly and fail fast.
InverseMethod is a sealed @DaTa type with all eight variants matched,
so the catch-all clause could never fire.
Concrete field types remove dynamic dispatch in designmatrix and
forwardmodel, which now pass @inferred. Drop the abstract return
annotations that masked the inferred return type.
The unparameterized F̄::SVD field was abstract, so F.U/F.S access in
gcv_svd was dynamically dispatched and boxed ~6500 Float64 scalars per
call. Parameterizing by the concrete SVD type makes gcv_svd type-stable
(6574 -> 3 allocations, 4.5x faster). The cached Āᵀ field was never
read, so drop it.
The comprehension evaluated x(i) once per (i,j) pair, so each of the n
basis vectors was rebuilt m times. Precompute them once, cutting
allocation ~19x and runtime ~5x for a 100x100 domain.
  - Incorporate CairoMakie library for plotting
  - Create a Figure and an Axis
  - Plot the true distribution, estimated distribution, and add labels and �[K
axis
- Update `smoothing.jl`:
  - Use CairoMakie for plotting
  - Create a Figure and an Axis
  - Plot the original data, regularization tools, and direct method, add la�[2D�[K
labels and axis
… point�[5D�[K

points
- Added `scatterlines!(ax, Dp, xλ, label = "Estimated")` to plot estimated �[K
data points
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant