Uncertainty and Units
Tracks physical units with pint and propagates measurement uncertainty via GUM and Monte Carlo, with local CLIs for budgets, reporting, code audits, and plausibility checks.
Data & AnalyticsAdvanced★ 33,030⑂ 3,248AI score 8/10Last updated: Aug 9, 2026
What it does
- Keeps units attached: enforces attaching units at input and stripping only at output with
m_as("unit"), and catches offset-temperature arithmetic, logarithmic units that multiply on+, and bare.magnitudecalls. - Propagates uncertainty properly: runs the GUM law of propagation (JCGM 100) and Monte Carlo (JCGM 101) on the same model, then applies the clause 8 validation test to decide which result may be reported.
- Builds uncertainty budgets: converts calibration-certificate expanded uncertainties and rectangular/triangular limits with the correct divisor, then computes u_c, sensitivity coefficients, Welch-Satterthwaite effective degrees of freedom, k from the t-distribution, and U.
- Formats results: rounds the uncertainty first, then the value, emitting
12.346 ± 0.023 mm,12.346(23) mm, scientific and LaTeX forms, plus the sentence that must accompany the number. - Audits existing code statically: nine rules (UNIT001–CONST001) flag a missing
absolute_sigmaincurve_fit,np.stdwithoutddof,ufloatrebuilt from nominal/std_dev (destroying correlations), and hard-coded CODATA literals. Exit code 1 makes it CI-ready. - Sanity-checks magnitudes: 14 dimensionless groups (Reynolds, Peclet, Damkohler, Knudsen, Biot, Womersley...), characteristic scales like diffusion time and Debye length, and curated observed-magnitude bands — with dimensionality verified before any number is computed.
Who it's for
- Experimentalists and grad students who must report values with a defensible ±
- Metrology, calibration, and QA engineers working from certificates and data sheets
- Engineers/developers doing fluid, heat-transfer, or reaction calculations in Python
- Anyone reviewing someone else's analysis script for silent unit or uncertainty bugs
Examples
- Density budget: feed mass 250.0 g (u=0.05), diameter 20.0 mm and height 40.0 mm (rectangular) to
propagate_uncertainty.pyand get u_c, sensitivity coefficients, per-component budget in percent, effective dof, k, U, both Monte Carlo coverage intervals, and a verdict on the linearization. - Legacy code review:
audit_units.py --input analysis.py --fail-on mediumsurfaces acurve_fitcall missingabsolute_sigma=True, where parameter uncertainties differed by 31% on a synthetic fit. - Regime check: compute Reynolds for blood (1060 kg/m³, 0.5 mm/s, 8 µm, 3.5 mPa·s) to confirm laminar flow, or have "2 m eukaryotic cell" rejected as 4.3 decades outside the observed 5–100 µm band.
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/uncertainty-and-units folder from the GitHub repo K-Dense-AI/scientific-agent-skills into my ~/.claude/skills/uncertainty-and-units/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git /tmp/sci-skills && mkdir -p ~/.claude/skills && cp -r /tmp/sci-skills/skills/uncertainty-and-units ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and confirm your Python version with
python3 --version— the numeric CLIs need 3.12 or newer. - Clone the repository:
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git - Copy the skill into your Claude Code skills folder:
mkdir -p ~/.claude/skills && cp -r scientific-agent-skills/skills/uncertainty-and-units ~/.claude/skills/ - Install the dependencies in a virtual environment:
uv venv --python 3.13 && source .venv/bin/activate && uv pip install "pint==0.25.3" "uncertainties==3.2.3" "numpy==2.5.1" "scipy==1.18.0"(or usepython3 -m venv .venvpluspip installif you don't have uv). - Restart Claude Code and try a trigger phrase such as "sanity check these units" or "is this number physically reasonable?".
- Verify the tooling: run
python skills/uncertainty-and-units/scripts/format_result.py --value 12.34567 --uncertainty 0.02345 --unit mmand check that a formatted result is printed. Note the static auditor works with the standard library alone if you skip step 4.
View source on GitHub ↗License: MIT