Mathematical foundations
Scalars, Units, and Coordinate Systems
Learn how scalar quantities, measurement units, rescaling, and coordinate choices shape data before any algorithm sees it.
By the end you can
- Distinguish a scalar value from its unit, scale, and measurement process
- Explain how a change of coordinates can preserve an object while changing its numerical representation
- Recognize dimensionally invalid expressions and misleading feature scales
- Design a unit-and-coordinate audit for an ML dataset
Visual
The anatomy of a measured scalar
A stored number is the smallest part of a feature. Around it sit the unit it is expressed in, the origin its differences are measured from, the process that produced it, and the range of decisions it is accurate enough to support. Strip any one of those layers away and the number survives intact. Its meaning does not.
Pounds mistaken for kilograms is a documented category of medication error, and the Pennsylvania Patient Safety Authority counted it. It analysed 479 medication-error reports involving patient weights, submitted between June 2004 and the end of November 2008. 129 of them — 26.9% — were classified as "Confusion between pounds versus kilograms". 322 of the 479 events, 67.2%, reached the patient, and 43.4% were wrong dose or overdosage. The Authority stated the pattern in its own words: “In fact, more than 25% of the 479 reports mention breakdowns that occurred when the patient’s weight, measured in pounds or kilograms, was erroneously documented as the patient’s weight in kilograms or pounds, respectively.”
The whole mechanism fits inside one stored value. NCC MERP's 2018 weighing recommendation gives it as “a weight of 220 lb. documented as 220 kg instead of 100 kg”. Nothing about the number 220 is wrong. It is a correct reading in one unit and a greater-than-two-fold dosing error in the other, and the column that holds it cannot tell you which. So the remedy is not a better model of the data. It is a change to the measurement process itself: metric-only documentation, and scales locked out of pounds.
- 01
Observed value
The number written in the table, such as 72.4.
- 02
Unit and scale
The measurement system, such as kilograms, cents, seconds, or a standardized score.
- 03
Reference point
The origin against which differences are interpreted, such as calendar time or temperature zero.
- 04
Measurement process
The instrument, aggregation rule, rounding, censoring, and missingness mechanism that produced the value.
- 05
Intended use
The decisions for which the measurement is sufficiently accurate and comparable.
Two identical stored values can represent different evidence when their measurement processes differ.
A number without context is not yet a feature
A scalar is a single numerical value, and its meaning depends on how it was measured. The value 20 could be degrees Celsius, kilograms, milliseconds, or a count of previous purchases. The value 220, as the 479 Pennsylvania reports show, can mean a 100 kg patient or a dose calculated for someone twice that mass. Machine-learning pipelines often strip that context away. A warehouse column may hold clean numbers while mixing currencies, time zones, sensor calibrations, and definitions from different teams. Mathematics begins before modeling, at the moment we decide which quantities are comparable. Units, origins, and scales determine whether addition, subtraction, ratios, and distances make sense at all.
The first mathematical question about a feature is not its distribution; it is what the number measures.
Case
A unit that was never converted cost NASA an orbiter
A lost unit cost NASA a spacecraft in 1999. The Mars Climate Orbiter Mishap Investigation Board reported on 10 November 1999 that the root cause was “the failure to use metric units in the coding of a ground software file”. The SM_FORCES output was required by the interface specification to be in Newton-seconds. The ground software reported it in pound-seconds. A pound-second is 4.45 Newton-seconds, so the navigation software “underestimated the effect on the spacecraft trajectory by a factor of 4.45”, and the error accumulated across every thruster firing of the cruise. The arrival figure is the one worth remembering: “At the time of Mars insertion, the spacecraft trajectory was approximately 170 kilometers lower than planned.”
No equation in the navigation code was wrong. Every number it consumed was numerically valid, well-formed, and in range. The only defective element was a label that existed in the specification and not in the data.
Example
Unit failures that look like model failures
These incidents are mathematical before they are algorithmic, and the fullest documented example is an aircraft.
On 23 July 1983 Air Canada Flight 143 ran out of fuel over Ontario and landed without engines at Gimli, Manitoba. The aircraft was a Boeing 767, registered C-GAUN. The board of inquiry under Mr Justice George H. Lockwood reported in April 1985 and reconstructed the arithmetic step by step.
Drip-stick readings of 62 and 64 cm gave 3,758 + 3,924 = 7,682 litres already on board. The crew multiplied 7,682 by the fuelling conversion factor 1.77 and obtained 13,597, which they treated as kilograms. The flight plan required 22,300 kg, so 22,300 − 13,597 = 8,703, and 8,703 / 1.77 = 4,916 litres to be added, rounded at the fueller's suggestion to the 5,000 litres actually boarded in Montreal. The commissioner's finding on that step is one sentence: “Multiplying by 1.77 gave pounds, but everyone involved thought they were kilograms.”
The correct calculation divides by 2.2 as well. 7,682 x 1.77 / 2.2 = 6,180 kg on board. 22,300 − 6,180 = 16,120 kg still required, which called for 20,036 litres rather than 5,000. The aircraft was cruising at 41,000 feet when the low-fuel-pressure warnings began, and both engines failed as it descended through 35,000 feet. Every multiplication was performed correctly. The factor 1.77 simply carried a unit that nobody read.
- Currency conversion: Revenue recorded in dollars and cents can create a hundred-fold discontinuity if the unit flag is lost. It is the same shape of error as 1.77 lb/L read as kg/L, differing only in the size of the constant.
- Time duration: Milliseconds mixed with seconds can make a latency model treat one service as three orders of magnitude slower. Nothing in the values themselves marks the boundary between the two populations.
- Temperature: Celsius and Fahrenheit are related by a scaling and an offset, so ratios such as “twice as hot” are not meaningful. Only differences survive the conversion, and only after the offset is handled.
- Calendar timestamps: A timestamp inherits a chosen origin and a chosen tolerance. Both are revisable decisions of a governing body rather than properties of the data. IERS Bulletin C 72, dated 6 July 2026, states “from 2017 January 1, 0h UTC, until further notice : UTC-TAI = -37 s”, and announces no leap second at the end of December 2026. Leap seconds are inserted whenever UT1-UTC is predicted to approach 0.9 s. Resolution 4 of the 27th General Conference on Weights and Measures, in 2022, warns that “the consequent introduction of leap seconds creates discontinuities that risk causing serious malfunctions in critical digital infrastructure including the Global Navigation Satellite Systems (GNSSs), telecommunications, and energy transmission systems”, and “decides that the maximum value for the difference (UT1-UTC) will be increased in, or before, 2035”. Unix time is suitable for ordering, but its raw magnitude may encourage a model to learn deployment-era artifacts.
- Rates and counts: Ten purchases over one day and ten purchases over one year are equal counts and very different behavioral evidence. The denominator is part of the quantity even when it is absent from the column.
Coordinates describe an object; they are not the object
A point on a map can be described by latitude and longitude, by local east–north coordinates, or by a three-dimensional vector from Earth’s center. The location stays the same while its coordinates change.
Australia performed the demonstration at continental scale. Geoscience Australia launched GDA2020 on 15 December 2017 and announced it plainly: “Australia's coordinates have officially moved 1.8 metres northeast, with Minister for Resources and Northern Australia Matt Canavan today launching Australia's new coordinate reference frame, the Geocentric Datum of Australia 2020 (GDA2020).” Nothing on the ground moved relative to anything else. The datum was re-referenced because the Australian plate travels roughly seven centimetres a year, which had left the 1994 datum 1.6 m out of sync with satellite positioning. GDA2020 is realised through the coordinates of the Australian Fiducial Network, and UN-GGIM records that those coordinates are given “in the International Terrestrial Reference Frame 2014 (ITRF2014) at the Reference Epoch”, the reference epoch being 1 January 2020. A fence that had one pair of numbers in December 2017 has another pair now. It is the same fence.
The same principle appears throughout ML. A document can be represented by word counts, latent topics, or an embedding. A rotation of an embedding space changes individual coordinates but may preserve angles and distances. Coordinate-aware reasoning prevents false conclusions from raw parameter values. A large coefficient can become small after rescaling while the represented prediction function stays exactly as it was. That is the 1.8 metre version of the same fact.
Comparison
Rescaling, centering, and changing units are not the same operation
All three alter numbers, and they preserve different relationships. Unit conversion multiplies by a known constant, so ratios and ordering survive, provided the label travels with the value. Centering subtracts a reference such as a mean or a baseline: it moves the origin, preserves every pairwise difference, and gives zero a new meaning. Standardization centers and then divides by a scale estimate, producing dimensionless coordinates. Unlike the other two, it changes the relative distances between features. That is exactly why it changes what a distance-based model sees.
That last claim has been measured. Wongoutong ran k-means on ten real datasets and published the results in PLOS ONE in 2024. On the Penguins data — 4 features in different units, 342 objects, 3 classes — accuracy was 0.5614 on the raw data and 0.9620 after Z-score standardization. Precision moved from 0.4949 to 0.9578. A chi-square homogeneity test against the true grouping was rejected at p<0.001 for the raw data, and not rejected, p=0.925, after standardization. On the datasets whose features already shared a single unit, scaling changed almost nothing. The abstract states the finding: “The results of an experimental study show that, for features with different units, scaling them before k-means clustering provided better accuracy, precision, recall, and F-score values than when using the raw data.”
The effect is not confined to clustering. In Applied Soft Computing in 2023, de Amorim and colleagues compared 5 scaling techniques across 20 classification algorithms and 82 public datasets, and found the gap between the best and the worst scaling technique to be relevant and statistically significant in most cases. Scaling is not a formatting step applied after the modeling decisions are made. On the same 342 penguins it is worth more than a third of the accuracy.
Unit conversion
Changes the numerical scale while preserving the underlying physical quantity.
- Example: meters to centimeters
- Multiplication by a known constant
- Ratios and ordering remain unchanged
- The unit label must change with the value
Centering
Subtracts a reference value such as a mean or baseline.
- Moves the coordinate origin
- Differences between observations are preserved
- The value zero gains a new interpretation
- Useful for covariance and optimization
Standardization
Centers and divides by a scale estimate.
- Produces dimensionless coordinates
- Changes relative distances across features
- Sensitive to outliers through the chosen scale
- Must be fitted only on allowed training data
Steps
A unit-and-coordinate audit
Coefficients, distances, and feature importance are worth auditing before they are interpreted. Name the quantity, and the entity and time grain it is measured at. Record the unit, including currencies, time zones, denominators, and implicit scaling factors. Identify the origin, and decide whether zero means absence, a baseline, or an arbitrary reference. Trace every transformation: centering, standardization, clipping, logarithms, and the statistics they were fitted on. Then test invariance, and ask which conclusions ought to survive an equivalent change of unit or coordinate.
Step three is the one that gets skipped, and Hubble is the definitive example of what skipping it costs. The 2.4 m primary mirror was polished with great precision to the wrong shape, leaving about 256 nm of spherical aberration. NASA's optical systems failure board, chaired by Lew Allen, reported in November 1990 that the aberration came from a measurement reference nobody re-checked: “It has been established that the field lens was approximately 1.3 mm too far from the lower mirror of the RNC, which was used to figure the primary mirror.” The displacement was traced to an interferometer that focused on the end cap of a metering rod whose anti-reflective coating had flaked away. The board found that the measured 1.3 mm error “accounts in detail for the amount and character of the observed image blurring”, and that “No verification of the reflective null corrector's dimensions was carried out by Perkin-Elmer after the original assembly”. Lallo recorded the same cause two decades later: “a 1.3 mm spacing error in the reflective null corrector device used to optically test the mirror while being figured”.
Precision measured against an unverified origin is precision in the wrong direction. It is also the failure mode hardest to detect from the data alone, because every reading is beautifully consistent with every other.
1. Name the quantity
Describe what is measured and at which entity and time grain.
2. Record the unit
Include currencies, time zones, denominators, and implicit scaling factors.
3. Identify the origin
Clarify whether zero means absence, a baseline, or an arbitrary reference point.
4. Trace transformations
Document centering, standardization, clipping, logarithms, and fitted statistics.
5. Test invariance
Check which conclusions should survive an equivalent unit or coordinate change.
Key idea
Dimensional analysis catches mistakes before training
Expressions should combine compatible quantities. Nobody can say what adding dollars to seconds would mean, while dividing dollars by seconds produces a rate with a new unit. ML systems sometimes hide dimensional errors inside feature engineering. Summing raw click counts with a normalized risk score may be legal code and meaningless mathematics.
Write the units beside a feature formula during review. If the resulting unit cannot be explained, the feature deserves scrutiny. This is the check that would have caught 7,682 x 1.77 before the aircraft left Montreal. The product of litres and a factor in lb/L is pounds, and the flight plan was written in kilograms.
Code can execute an operation that mathematics cannot justify.
Case
Since 2019 the kilogram is a constant rather than an object
Units are now anchored to constants rather than to objects. BIPM states the change directly: “From 20 May 2019 all SI units are defined in terms of constants that describe the natural world”, with the Planck constant h fixed at exactly 6.626 070 15 × 10⁻³⁴ J s. Before that date the kilogram was the outlier. As NIST puts it, “Before May 20, 2019, the kilogram was the lone remaining unit defined in terms of an artifact”.
Every reference end of a measurement is a choice someone had to make, and every one of them can be revised. A physical prototype replaced by a fixed constant. A 1994 datum replaced by GDA2020. A leap-second tolerance of 0.9 s that the 27th CGPM has already decided to widen in, or before, 2035. The values in a dataset inherit whichever choice was in force when they were recorded, and they carry no field that says which.
Key takeaways
- A scalar feature includes a value, unit, origin, measurement process, and intended interpretation: 129 of 479 Pennsylvania medication-error reports involving patient weights were pounds-versus-kilograms confusions, and 67.2% of those 479 events reached the patient.
- Unit conversion, centering, and standardization preserve different mathematical relationships, and mistaking one constant's unit for another's is how 7,682 litres became 13,597 supposed kilograms aboard Air Canada Flight 143.
- Coordinates can change while the represented object stays fixed: GDA2020 moved every Australian coordinate about 1.8 metres north-east on 15 December 2017 without moving anything on the ground.
- Feature scaling changes geometry and can materially alter distance-based models — k-means accuracy on the 342-object Penguins data was 0.5614 raw and 0.9620 after Z-score standardization.
- Dimensional analysis reveals invalid feature formulas that ordinary type systems allow, as the Mars Climate Orbiter board found when pound-seconds entered software specified in Newton-seconds and the trajectory came in about 170 kilometers low.
- A trustworthy interpretation should state which conclusions remain invariant under equivalent units or coordinates, and should re-verify its origin: Hubble's 2.4 m mirror was figured with great precision against a null corrector 1.3 mm out of place.