All examples
Scientific computing

Explicit measurement error sources

Construct source coefficient models, distinguish exact and unknown uncertainty, and inspect an acknowledged numerical export.

science_sources.aner
// An explicit coefficient matrix declares which independent sources affect each value.
import aner.tensor
import aner.science

let nominal = tensor.semantic([[20.0], [22.0]], "sensor", List("A", "B"), "degC")
let measured = science.measurements(nominal,
    List("calibration", "reading_A", "reading_B"), List(0.3, 0.2, 0.2),
    [[1.0, 1.0, 0.0], [1.0, 0.0, 1.0]], "delta_degC", "independent")
print("Variance at sensor A is 0.13 within tolerance")
let variance = measured.variance(0, 0)
print(variance > 0.129999999999 && variance < 0.130000000001)
print("Shared covariance is 0.09 within tolerance")
let covariance = science.covariance(measured, 0, 0, measured, 1, 0)
print(covariance > 0.089999999999 && covariance < 0.090000000001)
print("Each value retains two active source coefficients")
print(measured.source_entries())
print("Exact and unknown declarations preserve the nominal value")
let exact = science.exact(nominal.gather_rows(List(0)))
let unknown = science.unknown(nominal.gather_rows(List(0)))
print(exact.item())
print(exact.variance())
print(unknown.item())
// unknown.variance() would fail: unknown uncertainty cannot be interpreted as zero.
let exported = measured.export_values("Inspect nominal values with a values-only numerical tool")
print("The acknowledged export has two numeric rows")
print(tensor.rows(exported.values()))
print(tensor.value(exported.values(), 1, 0))

Make it your experiment.

With Aner installed, save this program as examples/science_sources.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/science_sources.aner
aner run examples/science_sources.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use native Aner 0.1.38 or newer with contextual data support on CPU Float64. The small synthetic example requires no external data or network connection.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner