Units, Dimensions, Scale, and Normalization
Install and import#
npm install fintech-algorithmsimport { unitsDimensionsScaleAndNormalization } from "fintech-algorithms/foundations/mathematical-language-and-quantitative-reasoning/units-dimensions-scale-and-normalization";Signature#
unitsDimensionsScaleAndNormalization(input)Rescales a series by subtracting an offset and dividing by a scale, so numbers recorded in one unit can be compared on a common footing.
Parameters#
| Name | Type | Notes |
|---|---|---|
input | D00Input | A plain object. Every F01 topic first reads values, which must be a non-empty array of finite numbers, and validates it before any per-topic branch runs. This topic then reads offset and scale, both coerced with Number, and sourceUnit, which is passed through untouched as a label. |
Returns#
{ normalized: number[]; sourceUnit: unknown; targetUnit: string }
normalized holds (value - offset) / scale for each entry in input order. sourceUnit is echoed back from the input and targetUnit is always the fixed label scaled units.
Errors#
- When input is not a plain object — throws TypeError
- When values is missing, empty, or not an array — throws RangeError
- When values contains a value that is not a finite number — throws RangeError
- When scale is zero — throws RangeError
Complexity: time O(n),
space O(n).
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#
{
"values": [1, 2, 3, 4, 5],
"startingCash": 1000,
"inflows": 250,
"outflows": 120,
"slope": 2,
"intercept": 1,
"part": 25,
"whole": 200,
"elapsed": 5,
"old": 4.5,
"new": 4.75,
"base": 16,
"exponent": 0.5,
"a": 2
}Showing 14 of 28 fields.
Call#
unitsDimensionsScaleAndNormalization(input)Returns#
object with 2 fields: normalized, sourceUnit
{
"normalized": [0, 0.5, 1, 1.5, 2],
"sourceUnit": "SAR millions"
}Diagrams#
Calculation flow#
Units, Dimensions, Scale, and Normalization — four-part map
flowchart LR
A["Name the input"] --> B["Apply: base amount = displayed amount × scale; per-unit amount = base amount / count"]
B --> C["Check units and boundary"]
C --> D["Explain the output"]
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.
References#
- The International System of Units (SI Brochure), 9th edition — Bureau International des Poids et Mesures
- NIST/SEMATECH e-Handbook of Statistical Methods — NIST/SEMATECH
- Author-derived and synthetic boundary