Scale & Offset
Shippingscale_offsetLinear transform y = a·x + b with configurable order
Signature
Inputs
signalSignalrequired
Outputs
resultSignal
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
scale | float | 1.0 | |
offset | float | 0.0 | |
order | enum | scale_then_offset | one of: scale_then_offset, offset_then_scale |
Description
Scale & Offset applies an affine (linear) transform to its input signal: it multiplies by a constant gain scale () and adds a constant bias offset (). The order parameter selects whether the offset is applied after scaling () or before scaling (), which are genuinely different transforms whenever .
The node operates sample-by-sample on the values of a Signal, preserving its timestamps and sample rate. It is purely memoryless — there is no state carried across samples or graph ticks — so the same input always produces the same output regardless of history.
Because scale and offset are treated as exact constants, uncertainty propagates by the linear rule: multiplying by scales the standard deviation by , and adding leaves it unchanged. Thus in both orderings. Physical units flow through unchanged; scale is dimensionless and offset is interpreted in the signal's own unit, so no rescaling of the unit label occurs.
This node is the canonical primitive for linear calibration, unit-preserving gain staging, and sign inversion (via a negative scale).
Mathematics
Examples
Two-point sensor calibration
A thermocouple front-end outputs raw millivolts that map linearly to temperature. Using the standard order , set scale to the slope and offset to the intercept obtained from a two-point fit:
scale = 24.98 # °C per mV
offset = -1.35 # °C
order = scale_then_offsetEvery input sample (mV) becomes (°C), with the input's uncertainty scaled by .
Bias removal before gain
To subtract a known DC pedestal before amplifying, choose offset_then_scale with a negative offset: . With scale = 10 and offset = -0.5, a signal is first shifted down by then multiplied by , unlike the reversed order which would yield .
Applications
- Linear calibration of sensor readings (thermocouples, load cells, pressure transducers) from raw counts or volts to engineering units.
- Gain staging and level trimming in signal chains, including sign inversion with a negative scale.
- Unit-consistent normalization, e.g. converting a 0–5 V ADC range to a 0–100% or physical span before downstream processing.
- Removing a known DC bias or applying a fixed setpoint offset in control and instrumentation pipelines.
Neat
The two `order` options are not redundant: $a x + b$ and $a(x + b)$ coincide only when $b = 0$; otherwise they differ by a factor of $a$ applied to the offset.
A negative `scale` acts as an exact sign inversion while still scaling uncertainty by $|a|$, so the standard deviation stays positive even as the mean flips.
Known issues
Setting `scale = 0` collapses the signal to a constant (`offset` or $a\cdot b = 0$) and forces $\sigma_y = 0$, discarding all input variability and uncertainty — this is mathematically correct but easy to trigger by accident.