Advanced Octave A39 — Uncertainties and error bars
Advanced GNU Octave with GX-TXT · Module 07
A measure is not only a number: it is also necessary to declare how its variability is evaluated. In this lesson we represent five synthetic calibration points with vertical symmetric bars.
Objectives and prerequisites
After the publication of A13 Dataset and A37 PlotSpec, we will use public writer and Plot v4. The test was performed with GX-TXT dev112-P011-bis and GNU Octave 9.4.0. It is assumed, in order to build the example, that the uncertainties provided are standard deviations in volts: the numbers are didactic and do not result from real measures.
Import barre_incertezza.m, record the script and run it in the Runner. The octave_advanced_calibration identifier is created-only: to repeat the test, use a new Session or change the ID in the script.
Preparing data
The writer creates three variables in the same Dataset: input_v input, output_v output and sigma_v standard deviation. All lines correspond to the same observations. For example, at the third position the output is 3.04 V with standard deviation 0.07 V: the bar represents the range from 2.97 to 3.11 V.
The PlotSpec uses kind = 'errorbar' and a y_error structure with mode = 'symmetric' and variable_id = 'sigma_v'. The reference identifies a variable of the Dataset, not a vector embedded in the configuration. validate_spec verifies the spec before creation; render produces the graph. For example, the validation returns 1.
Open the chart from the Plots tab, then enlarge it in the Viewer:
Each circle indicates the central value and each vertical segment extends a standard deviation above and below the value. The legend can overlap at the last point in the automatic layout: the value can be read in the original data. The two dimensions of the axes are expressed in volts.
Standard deviation and confidence interval
The standard deviation describes the dispersion of values according to the model and the data used to estimate it; a confidence interval instead concerns an estimated parameter and depends on the method, the level of confidence and the hypotheses. A standard ±1 deviation bar does not automatically become a 95% confidence interval. It always indicates in the legend or caption the meaning of the bars and the method by which they were obtained.
Exercise
- What extremes is the fourth bar?
- Why does
sigma_vhave to be aligned with the observations? - Is it correct to call these bars 95% confidence intervals without any other calculations?
Worked solution
- The 3.96 V value with standard deviation 0.12 V gives the extremities 3.84 and 4.08 V.
- Any uncertainty must be associated with the same line as the point it describes; trading the lines would attribute the bars to the wrong measures.
- No. It takes an estimate of the range and an appropriate method; here the bars represent only ±1 standard deviation assumed.
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