Advanced Octave A53 — Constrained problems and physical conditions

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

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

  1. What parameter reaches its limit?
  2. How does RMS of residue change in the test?
  3. Why is the limit on k too low in this example?

Worked solution

  1. k reaches the upper limit of 0.5 s⁻¹.
  2. It increases from approximately 0.010557 to 0.077930.
  3. Synthetic data has been generated with k = 0.6 s⁻¹, out of the imposed range.

Download the Module 09 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 *