> *The simplest transformations are often the most powerful—linear scaling is the mathematical equivalent of adjusting the volume and tuning the dial.*
The Linear transformer applies an affine transformation $y = \text{slope} \cdot x + \text{intercept}$ to each value in a time series. This fundamental operation enables scaling, offsetting, unit conversion, and normalization—the building blocks for preparing data for analysis or combining signals from different sources.
varoffset=newLineartrans(scale,1.0,10.0);// Chain: scale then add 10
// Equivalent to: Linear(2.0, 10.0)
```
## Common Pitfalls
1.**Zero Slope Trap**: Setting `slope=0` produces constant output regardless of input. This is valid but often unintentional.
2.**Division by Zero in Inverse**: When computing inverse transforms, ensure the original slope is non-zero.
3.**Overflow Risk**: Large slopes combined with large inputs can overflow. For slope=1e100 and x=1e100, the result exceeds double precision.
4.**Precision Accumulation**: While single transforms are precise, many chained transforms accumulate error. Use composition formula to combine into single transform when possible.
5.**Parameter Validation**: Constructor rejects NaN/Infinity for slope and intercept to fail fast rather than propagate invalid results.
## Validation
| Test | Status |
|:-----|:------:|
| **Mathematical Formula Parity** | ✅ |
| **Identity Transform** | ✅ |
| **Composition Property** | ✅ |
| **Inverse Recovery** | ✅ |
| **Difference Preservation** | ✅ |
| **FMA Accuracy** | ✅ |
## References
- Strang, G. (2016). *Introduction to Linear Algebra*. Wellesley-Cambridge Press.
- Goldberg, D. (1991). "What Every Computer Scientist Should Know About Floating-Point Arithmetic." *ACM Computing Surveys*.