Advanced Octave A33 — Constraints and shared parameters

by Giux GX-TXT, octave-en, scripts-en 2 min read

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

  1. What parameter is set and what is estimated?
  2. Why is k shared in this example?
  3. Fixing A to 3 shows that its value is known without uncertainty in a real experiment?

Worked solution

  1. The A width is fixed; k is free within limits.
  2. The two series are adapted together with the same vector of parameters.
  3. No. It is a model hypothesis that must be motivated and, if necessary, treated with its uncertainty.

Download the Module 06 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *