Statistical Interpretation and Scientific Reporting

by Giux GX-TXT, python-en, scripts-en 3 min read

Scientific Python in GX-TXT · Module 8 · Lesson 48

A scientific report must allow those who read to distinguish data, estimates, uncertainties and interpretations. In this lesson we build a brief example report starting from a regression performed in the Runner.

Objectives

  • Identify source, model and units.
  • Report parameters and residuals without inventing unavailable fields.
  • Distinguish a numerical solution from a scientific conclusion.
  • To declare limits and hypotheses of the example.

Data and model

We use corso_python_seconda_serie, a series of four synthetic points built on the signal = 1 + 0,2 × time_values straight. The time is in seconds and the signal in millivolt. The example is not an experiment.

At the corso_python Session, import report.py, save it and run it in the Runner.

Reporting script in the GX-TXT editor.
Reporting script in the GX-TXT editor.
import numpy as np
from gxtxt import gxtxt_api_call, gxtxt_api_require

for api in ("NUMERIC_API_v1@1", "CANONICAL_DATASET_API_v2@2"):
    gxtxt_api_require(api)
dataset = "corso_python_seconda_serie"
data_values = gxtxt_api_call("CANONICAL_DATASET_API_v2", "read_range", [dataset, ["tempo", "segnale"], 0, 4])
x = np.asarray(data_values["tempo"]["values"]).reshape(-1)
y = np.asarray(data_values["segnale"]["values"]).reshape(-1)
fit = gxtxt_api_call("NUMERIC_API_v1", "linear_regression", [x, y])
residuals = np.asarray(fit["residuals"]).reshape(-1)
print("DIDACTIC REPORT — Synthetic data")
print("Source:", dataset, "| campioni:", len(x))
print("Model: signal = intercept + slope × time")
print("Intercetta (mV):", fit["intercept"])
print("Pendenza (mV/s):", fit["slope"])
print("Maximum absolute residue (mV):", np.max(np.abs(residuals)))
print("Solution Status:", fit["status"])
print("Limits: four synthetic data; no causal evidence.")

The script reads canonical data, runs linear_regression and sums up the fields actually returned. The identity of the Dataset and the number of samples make the source recognizable; the names of the axes and the units explain the size of the parameters.

Job report showing parameters, residuals and limitations.
Job report showing parameters, residuals and limitations.

The esteem of the intercept is about 1 mV; the slope is 0,2 mV/s. The maximum absolute residual is the order of 10⁻¹⁶ mV, compatible with the numerical differences of an example built exactly on the straight. The ok state concerns the numerical solution: it does not prove that the model is physically valid or that a variable falls on the other.

Uncertainty and semantic

A more complete relationship may include uncertainty of parameters, correlations and intervals, but only when the method and assumptions make them available and interpretable. Do not replace an unavailable field with zero. The Curve Fitter of lesson 46 shows, for example, that a range can be indicated as unavailable in the absence of the required hypotheses. Statistical semantic APIs help preserve the meaning of results: they do not calculate new measures and do not eliminate the need to check the model.

In a report intended for others, add version of the code and software, parameters, origin and identity of the result, method, conventions and limits. A figure must have a caption consistent with the data actually shown.

Exercise

  1. What are the units of the two parameters?
  2. What does the maximum residue almost null indicate in this example?
  3. Can you get a causal relationship from the ok state of the solver?

Worked solution

  1. Interception in mV, slope in mV/s.
  2. That the expected straight reproduces very well these synthetic points; they were built on the straight.
  3. No. The state concerns the numerical solution, while a causal conclusion requires an appropriate design and hypotheses.

The next module will organize scripts in maintenanceable Python projects.

Download the Module 8 scripts (ZIP)

#GX-TXT #Python #Statistics

Other steps of this project

Leave a Reply

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