Advanced Octave A32 — Nonlinear fitting and initialization
Advanced GNU Octave with GX-TXT · Module 06
In a non-linear fit, the initial values can influence research. Comparing more reasonable initializations is a useful control, although without guaranteeing by itself to have found the best possible solution.
Objectives and data
We repeat regression and callback from the introductory course and the A23 lesson. We adapt A exp(−k t) to 21 synthetic values generated with A=3, k=0,5 and a small deterministic sinusoidal disturbance. They are not measures and perturbation is not a statistical model of noise. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0.
Compare two initial points
Import fit_esponenziale.m, record it in the Session and start it in the Runner.
The program records a callback @(p,x) p(1)*exp(-p(2)*x) and calls NUMERIC_API_v1/nonlinear_fit with the same observations but two initial vectors: (2; 0,2) and (4; 1). The cleaning section releases the callback.
In the test both attempts report convergence and parameters about A=3,0081 and k=0,5009, which coincide with the accuracy displayed. They are close to the values used to generate the ideal signal, but the added disturbance explains why they should not coincide exactly.
What to control beyond convergence
The two initializations examined achieve similar results in this case; other functions or intervals may have minimum local, unidentified parameters or convergence failures. Diagnostic verification, residues, parameter scale and data hypotheses. If the solver does not converge, do not present the parameters as a successful fit.
In a physical application declares the units: if the time is in seconds, k is in s⁻¹; the amplitude has the response unit. The compatibility of the units is part of the model and is not automatically deducted from the formula.
Exercise
- Why are the estimated parameters not exactly
3and0,5? - Two similar results show that every possible initialization will work?
- Which unit has
kif the time is expressed in seconds?
Worked solution
- The synthetic signal includes a deterministic disturbance in addition to the ideal exponential model.
- No. It is a limited verification to the two initial points tested.
- Seconds at least one,
s⁻¹.
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