fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Measurement Error, Resolution, Accuracy, and Precision

Install and import#

bash
npm install fintech-algorithms
ts
import { measurementErrorResolutionAccuracyAndPrecision } from "fintech-algorithms/foundations/data-variables-samples-and-measurement/measurement-error-resolution-accuracy-and-precision";

Signature#

measurementErrorResolutionAccuracyAndPrecision(input)

Compares repeated measurements against a known reference to separate accuracy from precision, and reports the smallest gap between the distinct values present in the sample.

Parameters#

NameTypeNotes
inputD00InputA plain object. Every F03 topic first reads rows, which must be a non-empty array of row objects, and derives the sorted union of every key seen across them before any per-topic branch runs, even though this topic does not use them. The calculation itself reads measurements, a non-empty array of finite numbers, and referenceValue, the true value they are aimed at.

Returns#

{ bias: number; mae: number; resolution: number; precisionStd: number }

bias is the mean signed error against referenceValue and mae is the mean absolute error. resolution is the smallest gap between consecutive distinct measurements: an observed spacing in this sample, which is a lower bound on the recording step and not a measurement of the instrument's own display increment. precisionStd is the population standard deviation of the measurements, dividing by n rather than n-1.

Errors#

  • When input is not a plain object — throws TypeError
  • When rows is missing, empty, or not an array — throws RangeError
  • When measurements is missing, empty, not an array, or contains a non-finite number — throws RangeError
  • When every measurement is the same number, so no gap between distinct values exists — throws RangeError in TypeScript and ValueError in Python; the topic facade rejects this state rather than reporting a placeholder resolution

Complexity: time O(r * c + m log m), space O(r * c + m).

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

input
{
  "rows": [
    {
      "entity": "A",
      "timestamp": "2025-01-01T00:00:00Z",
      "value": 10,
      "rating": "low"
    },
    {
      "entity": "A",
      "timestamp": "2025-01-02T00:00:00Z",
      "value": null,
      "rating": "medium",
      "censored": true
    },
    {
      "entity": "B",
      "timestamp": "2025-01-01T00:00:00Z",
      "value": 12,
      "rating": "high"
    }
  ],
  "ordinalColumns": ["rating"],
  "populationSize": 100,
  "frameSize": 80,
  "keyColumns": ["entity", "timestamp"],
  "truncationRule": "values below 5 excluded",
  "measurements": [9.9, 10, 10.1, 10],
  "referenceValue": 10,
  "vintages": [
    {
      "availableAt": "2025-02-01T00:00:00Z",
      "value": 100
    },
    {
      "availableAt": "2025-03-01T00:00:00Z",
      "value": 102
    },
    {
      "availableAt": "2025-04-01T00:00:00Z",
      "value": 101
    }
  ],
  "asOf": "2025-03-15T00:00:00Z",
  "provenance": {
    "source": "teaching.csv",
    "owner": "Fintech Builder",
    "license": "CC-BY-4.0",
    "retrievedAt": "2026-08-10",
    "transformations": ["parse", "validate"]
  }
}

Call#

measurementErrorResolutionAccuracyAndPrecision(input)

Returns#

object with 4 fields: bias, mae, resolution, precisionStd

{
  "bias": 0,
  "mae": 0.05,
  "resolution": 0.1,
  "precisionStd": 0.0707106781186545
}

Diagrams#

Measurement Error, Resolution, Accuracy, and Precision — article hero
Measurement Error, Resolution, Accuracy, and Precision — concept anatomy
Measurement Error, Resolution, Accuracy, and Precision — mistake contrast
Measurement Error, Resolution, Accuracy, and Precision — teaching map

Calculation flow#

Concept flow — D00-F03-A08
flowchart LR
    A["Synthetic records"] --> B["Declare meaning"]
    B --> C["Run diagnostic"]
    C --> D{"Assumption survives?"}
    D -->|Yes| E["Explain: bias = 0.00; mean absolute error = 0.05"]
    D -->|No| F["Stop and repair metadata"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • Accuracy
  • Terminology
  • Evidence boundary

The rest of the Data, Variables, Samples, and Measurement family#