Advanced Octave A50 — Sensitivity to parameters and initial conditions
Advanced GNU Octave with GX-TXT · Module 09
How much does a prediction change if a parameter varies slightly? A local numerical derivative helps to respond close to a nominal value, without replacing an exploration of the entire domain.
Objectives and prerequisites
We repeat the equations A → B → C of A49. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import sensibilita.m, register it and run it in the Runner. The resulting dataset octave_advanced_sensitivity is created-only: to repeat, use a new session or change the ID.
End-of-centered differences
We set k2 = 0,2 s⁻¹ and the initial conditions [1; 0; 0]; we solve the system three times with k1 = 0,49, 0,50 and 0,51 s⁻¹. At every moment the local sensitivity of fraction B compared to k1 is approximated by:
[B(k1+h) - B(k1-h)] / (2*h), with h = 0,01 s⁻¹.
The fraction is dimensionless, while k1 has s⁻¹ units: the sensitivity therefore has second units. The script publishes it as a series over time and uses NUMERIC_API_v1 to calculate the average in the sample times.
At 5 s the test returns B about 0.475783, 0.476324 and 0.476764 respectively for the three values of k1. The central difference estimates a sensitivity of about 0.049054 s at the nominal point. The positive sign indicates that, in this small around and at this moment, increasing k1 B increases.
What he tells and what he doesn’t tell
Sensitivity changes with time and with the chosen point: it is not a law that is automatically valid for large variations. Repeat with different h steps helps to evaluate the numerical approximation and accuracy effect. You can apply the same principle to the initial conditions, paying attention to preserving constraints such as the sum of fractions; changing one state without compensating others would change the initial total.
Exercise
- What values of
k1are used for the center difference? - What is the sensitivity unit of a fraction compared to
k1? - Does the 5 s result necessarily apply to 12 s or for a large variation of
k1?
Worked solution
- 0.49 and 0.51 s⁻¹ around the nominal value 0.50 s⁻¹.
- Seconds.
- No: Sensitivity is local both in the parameter and in the instant considered.
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