Advanced Octave A53 — Constrained problems and physical conditions
Advanced GNU Octave with GX-TXT · Module 09
A bond can incorporate physical knowledge into the estimate, but a wrong range can prevent the model from adapting to data. We see both effects on a synthetic example.
Objectives and prerequisites
We repeat the decay and synthetic data of A52. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import calibrazione.m, register it and run it in the Runner.
Compare two estimates
The callback describes A*exp(-k*t). The first call to NUMERIC_API_v1/nonlinear_fit is free; the second calls 1 ≤ A ≤ 3 and 0,1 ≤ k ≤ 0,5 s⁻¹. The limits are chosen for the exercise: the upper one on k is intentionally too low compared to the 0.6 s⁻¹ value used to generate data.
In the test the unconstrained estimate gives A≈ 2.002807 and k ≈ 0.600515 s⁻¹, with RMS of the residuals ≈ 0.010557. The constrained estimate converges to A≈ 1.865366 and k = 0.5 s⁻¹, with RMS ≈ 0.077930. active_bounds reports that the second parameter is on a limit.
The binding result respects the required ranges, but the adjustment significantly worsens. The active limit is an invitation to control the justification of the bond, the residues and the pattern; it is not alone evidence that a specific hypothesis is wrong. Here we know that the limit is too restrictive because we know how the data was generated.
Use motivated constraints
In a real problem the ranges can result from units, physical laws, independent measures or limits of the apparatus. Document the source and compare plausible scenarios. Convergence means that the algorithm has met its numerical criterion: it does not guarantee that the model or constraints are physically valid. Uncertainties near an active limit require special caution.
Exercise
- What parameter reaches its limit?
- How does RMS of residue change in the test?
- Why is the limit on k too low in this example?
Worked solution
- k reaches the upper limit of 0.5 s⁻¹.
- It increases from approximately 0.010557 to 0.077930.
- Synthetic data has been generated with k = 0.6 s⁻¹, out of the imposed range.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories