mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-04 12:07:44 +00:00
35a6702b06
Deep review of all indicator categories verified .md headers against .cs WarmupPeriod, parameters, inputs, and outputs. Fixes include warmup corrections, parameter documentation, output type accuracy, and Pine Script alignment.
81 lines
2.9 KiB
Markdown
81 lines
2.9 KiB
Markdown
# RMSE: Root Mean Squared Error
|
|
|
|
| Property | Value |
|
|
| ---------------- | -------------------------------- |
|
|
| **Category** | Error Metric |
|
|
| **Inputs** | Actual, Predicted (dual series) |
|
|
| **Parameters** | `period` |
|
|
| **Outputs** | Single series (RMSE) |
|
|
| **Output range** | $\geq 0$ |
|
|
| **Warmup** | `period` bars |
|
|
|
|
### TL;DR
|
|
|
|
- Root Mean Squared Error (RMSE) is the square root of MSE, providing an error metric in the same units as the original data while retaining sensitiv...
|
|
- Parameterized by `period`.
|
|
- Output range: $\geq 0$.
|
|
- Requires 1 bar of warmup before first valid output (IsHot = true).
|
|
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
|
|
|
> "MSE's more interpretable sibling that speaks the language of your data."
|
|
|
|
Root Mean Squared Error (RMSE) is the square root of MSE, providing an error metric in the same units as the original data while retaining sensitivity to large errors.
|
|
|
|
## Mathematical Foundation
|
|
|
|
### Formula
|
|
|
|
$$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2} = \sqrt{MSE}$$
|
|
|
|
## Properties
|
|
|
|
* **Non-negative**: RMSE ≥ 0
|
|
* **Same units**: Unlike MSE, RMSE is in original data units
|
|
* **Outlier sensitive**: Inherits MSE's penalty for large errors
|
|
* **Always ≥ MAE**: RMSE ≥ MAE due to Jensen's inequality
|
|
|
|
## Usage
|
|
|
|
```csharp
|
|
var rmse = new Rmse(period: 20);
|
|
var result = rmse.Update(actualValue, predictedValue);
|
|
|
|
// Batch calculation
|
|
var results = Rmse.Calculate(actualSeries, predictedSeries, period: 20);
|
|
```
|
|
|
|
## Performance Profile
|
|
|
|
### Operation Count (Streaming Mode)
|
|
|
|
O(1) per bar. Single-pass scalar transformation of (actual, forecast) pair; no lookback window required.
|
|
|
|
| Operation | Count | Cost (cycles) | Subtotal |
|
|
| :--- | :---: | :---: | :---: |
|
|
| Error computation (subtract, abs/square/log) | 1-3 | ~3-8 cy | ~5-15 cy |
|
|
| Running accumulator update (EMA or sum) | 1 | ~4 cy | ~4 cy |
|
|
| **Total** | **2-4** | — | **~9-19 cycles** |
|
|
|
|
Streaming update requires only the current actual/forecast pair and running state. ~10-15 cycles/bar typical.
|
|
|
|
### Batch Mode (SIMD Analysis)
|
|
|
|
| Operation | Vectorizable? | Notes |
|
|
| :--- | :---: | :--- |
|
|
| Element-wise error computation | Yes | Independent per bar; fully vectorizable with `Vector<double>` |
|
|
| Reduction (sum/mean) | Yes | Parallel reduction; AVX2 gives 4x speedup |
|
|
| Log/exp components | Partial | Transcendental ops; polynomial approx for SIMD |
|
|
|
|
Batch SIMD: 4x-8x speedup for large windows. ~3-5 cy/bar amortized in vectorized batch mode.
|
|
|
|
| Metric | Score | Notes |
|
|
| :--- | :--- | :--- |
|
|
| **Throughput** | ~15 ns/bar | O(1) with sqrt operation |
|
|
| **Allocations** | 0 | Pre-allocated ring buffer |
|
|
| **Complexity** | O(1) | Constant time per update |
|
|
|
|
## Related Indicators
|
|
|
|
* [MSE](../mse/Mse.md) - Mean Squared Error
|
|
* [MAE](../mae/Mae.md) - Mean Absolute Error
|