Advanced Octave A33 — Constraints and shared parameters
Advanced GNU Octave with GX-TXT · Module 06
A fit can impose that some sizes are known or that more series share a parameter. These choices reduce the degrees of freedom, but they are the hypotheses of the model and must be motivated.
Objectives and data
After the non-linear fit of A32 and the introductory course, we adapt two synthetic series with the same model A exp(−k t). Both are built with A=3 and k=0,5, adding opposite deterministic disturbances. They are not independent measures or experimental data. The test uses GX-TXT dev112-P011-bis and Octave 9.4.0.
We set A=3 and compile a single k shared by both series, limiting it to the [0,2] range. In a real situation, fixing exactly a parameter known only with uncertainty could substimate the overall uncertainty.
Building the fit
Import fit_condiviso.m, register it and run it in the Runner.
The script concatenates the times and answers of the two series and uses a single callback:
X = [t;t];
y = [3*exp(-0.5*t)+0.02*sin(3*t); ...
3*exp(-0.5*t)-0.02*sin(3*t)];
h = gxtxt_callback_register(@(p,x) p(1)*exp(-p(2)*x));
options = struct('fixed_mask',[true,false], 'lower_bounds',[3,0], ...
'upper_bounds',[3,2]);
result = gxtxt_api_call('NUMERIC_API_v1','nonlinear_fit',{X,y,h,[3,0.7],options});
fixed_mask indicates that the first parameter is not optimized; the second is free within declared limits. Since all points have passed to the same model with the same vector of parameters, k is common to the two series. In this example the fixed width is also common: we are not estimating separate widths for the two groups.
In the test the solver reports convergence, parameters about [3; 0,5] and a free parameter. The 3 value is imposed, not estimated by data. The result close to 0,5 is consistent with the chosen synthetic model and opposite art-built disturbances.
Interpreting constraints
A parameter close to a limit may require interpretations and methods of uncertainty other than a free parameter within the domain. Check active_bounds, convergence and uncertainty fields available in the result; do not replace unavailable uncertainty with zero. The sharing of a parameter is only justified if the model and conditions of the groups support it.
Exercise
- What parameter is set and what is estimated?
- Why is
kshared in this example? - Fixing
Ato 3 shows that its value is known without uncertainty in a real experiment?
Worked solution
- The
Awidth is fixed;kis free within limits. - The two series are adapted together with the same vector of parameters.
- No. It is a model hypothesis that must be motivated and, if necessary, treated with its uncertainty.
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