validation and profiles

This commit is contained in:
Miha Kralj
2026-02-26 22:02:52 -08:00
parent 9ab37c1200
commit 8a1ba95173
317 changed files with 18704 additions and 622 deletions
+26 -1
View File
@@ -1,4 +1,4 @@
# Huber: Huber Loss
# Huber: Huber Loss
> "The Goldilocks of loss functions: not too sensitive, not too robust, just right."
@@ -86,6 +86,31 @@ Huber.Batch(actualSpan, predictedSpan, outputSpan, period: 20, delta: 1.345);
## Performance Profile
### Operation Count (Streaming Mode)
Huber loss: L = 0.5*e^2 if |e|<=delta, else delta*(|e| - 0.5*delta). Conditional on residual vs threshold; two paths.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Residual e = actual - forecast | 1 | ~2 cy | ~2 cy |
| Absolute value + comparison vs delta | 1 | ~3 cy | ~3 cy |
| Quadratic path: 0.5*e^2 | 1 | ~4 cy | ~4 cy |
| Linear path: delta*(|e| - 0.5*delta) | 2 | ~4 cy | ~8 cy |
| Running accumulator update | 1 | ~4 cy | ~4 cy |
| **Total** | **~5** | — | **~15 cycles** |
O(1) per bar. Branch prediction favors the quadratic path for small errors. ~15 cycles/bar.
### Batch Mode (SIMD Analysis)
| Operation | Vectorizable? | Notes |
| :--- | :---: | :--- |
| Residual computation | Yes | Element-wise subtract |
| Conditional Huber selection | Yes | Branchless via SIMD blend/mask |
| Accumulation | Yes | Parallel reduction |
Branchless SIMD implementation eliminates branch mispredictions. ~4 cy/bar in batch mode.
| Metric | Score | Notes |
| :--- | :--- | :--- |
| **Throughput** | ~12 ns/bar | O(1) update complexity |
+27 -1
View File
@@ -1,4 +1,4 @@
# Log-Cosh: Logarithm of Hyperbolic Cosine Loss
# Log-Cosh: Logarithm of Hyperbolic Cosine Loss
> "The smooth operator that acts like L2 for small errors and L1 for large ones."
@@ -89,6 +89,32 @@ LogCosh.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
## Performance Profile
### Operation Count (Streaming Mode)
LogCosh: L = log(cosh(e)) = log((exp(e)+exp(-e))/2). Numerically stabilized as |e| + log(1+exp(-2|e|)) - log(2).
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Residual e = actual - forecast | 1 | ~2 cy | ~2 cy |
| Absolute value + two exp() calls | 2 | ~15 cy | ~30 cy |
| log() call | 1 | ~15 cy | ~15 cy |
| Arithmetic combination | 3 | ~3 cy | ~9 cy |
| Running accumulator update | 1 | ~4 cy | ~4 cy |
| **Total** | **~8** | — | **~60 cycles** |
O(1) per bar. LogCosh is dominated by transcendental function costs (exp, log). ~60 cycles/bar.
### Batch Mode (SIMD Analysis)
| Operation | Vectorizable? | Notes |
| :--- | :---: | :--- |
| Residual computation | Yes | Element-wise |
| exp() calls | Partial | Polynomial SIMD approximation gives 4x speedup |
| log() call | Partial | Same polynomial approximation |
| Accumulation | Yes | Parallel reduction |
Batch SIMD with polynomial exp/log: ~15-20 cy/bar.
| Metric | Score | Notes |
| :--- | :--- | :--- |
| **Throughput** | ~18 ns/bar | O(1) update, log/cosh computation |
+23 -1
View File
@@ -1,4 +1,4 @@
# MAAPE: Mean Arctangent Absolute Percentage Error
# MAAPE: Mean Arctangent Absolute Percentage Error
> "When percentage errors need boundaries, arctangent provides the walls."
@@ -87,6 +87,28 @@ Maape.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~20 ns/bar | O(1) update, arctan computation |
+23 -1
View File
@@ -1,4 +1,4 @@
# MAE: Mean Absolute Error
# MAE: Mean Absolute Error
> "When you need to know how wrong you are on average, without the drama of squared errors."
@@ -78,6 +78,28 @@ Mae.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~10 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# MAPD: Mean Absolute Percentage Deviation
# MAPD: Mean Absolute Percentage Deviation
> "Like MAPE, but divides by what you predicted instead of what actually happened."
@@ -80,6 +80,28 @@ Mapd.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~12 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# MAPE: Mean Absolute Percentage Error
# MAPE: Mean Absolute Percentage Error
> "The metric that lets you compare apples to oranges, as long as you don't have any zeros."
@@ -80,6 +80,28 @@ Mape.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~12 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# MASE: Mean Absolute Scaled Error
# MASE: Mean Absolute Scaled Error
> "A good forecast is one that's better than guessing. MASE tells you exactly how much better."
@@ -41,6 +41,28 @@ $$\text{MASE} = \frac{\text{MAE}}{\text{Scale}}$$
## 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** | ~35 ns/bar | Dual running sums for error and scale |
+23 -1
View File
@@ -1,4 +1,4 @@
# MdAE: Median Absolute Error
# MdAE: Median Absolute Error
> "When outliers scream but you need to hear the whisper of typical performance."
@@ -82,6 +82,28 @@ Mdae.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~20 ns/bar | O(1) with sorted buffer |
+23 -1
View File
@@ -1,4 +1,4 @@
# MdAPE: Median Absolute Percentage Error
# MdAPE: Median Absolute Percentage Error
> "When you need relative errors but can't trust the outliers."
@@ -79,6 +79,28 @@ Mdape.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~25 ns/bar | O(1) with sorted buffer |
+23 -1
View File
@@ -1,4 +1,4 @@
# ME: Mean Error (Mean Bias Error)
# ME: Mean Error (Mean Bias Error)
> "Sometimes you need to know not just how wrong you are, but which direction you're wrong in."
@@ -81,6 +81,28 @@ Me.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~10 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# MPE: Mean Percentage Error
# MPE: Mean Percentage Error
> "MAPE tells you how wrong you are; MPE tells you which direction you're wrong in."
@@ -48,6 +48,28 @@ When errors alternate: $|\text{MPE}| < \text{MAPE}$
## 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) via running sum |
+23 -1
View File
@@ -1,4 +1,4 @@
# MRAE: Mean Relative Absolute Error
# MRAE: Mean Relative Absolute Error
> "When you need to understand your error in the context of what you're predicting."
@@ -78,6 +78,28 @@ Mrae.Batch(actualSpan, predictedSpan, outputSpan, 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) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# MSE: Mean Squared Error
# MSE: Mean Squared Error
> "The metric that makes outliers pay dearly for their transgressions."
@@ -69,6 +69,28 @@ Mse.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~12 ns/bar | O(1) with one multiplication |
+23 -1
View File
@@ -1,4 +1,4 @@
# MSLE: Mean Squared Logarithmic Error
# MSLE: Mean Squared Logarithmic Error
> "When your data spans orders of magnitude, MSLE keeps outliers from hijacking your loss function."
@@ -44,6 +44,28 @@ $$\text{MSLE}_t = \frac{1}{n} \sum_{i=t-n+1}^{t} e_i$$
## 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** | 25 ns/bar | O(1) via running sum |
+23 -1
View File
@@ -1,4 +1,4 @@
# Pseudo-Huber: Smooth Huber Approximation
# Pseudo-Huber: Smooth Huber Approximation
> "All the robustness of Huber, none of the discontinuities."
@@ -92,6 +92,28 @@ PseudoHuber.Batch(actualSpan, predictedSpan, outputSpan, period: 20, delta: 1.0)
## 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) update, sqrt computation |
+23 -1
View File
@@ -1,4 +1,4 @@
# Quantile Loss: Pinball Loss Function
# Quantile Loss: Pinball Loss Function
> "When over-prediction and under-prediction carry different costs, quantiles find the balance."
@@ -94,6 +94,28 @@ QuantileLoss.Batch(actualSpan, predictedSpan, outputSpan, period: 20, tau: 0.9);
## 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** | ~12 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# RAE: Relative Absolute Error
# RAE: Relative Absolute Error
> "How much better than just guessing the mean? RAE gives you the ratio."
@@ -37,6 +37,28 @@ $$\text{RAE} = \frac{\sum_{t=1}^{n} |y_t - \hat{y}_t|}{\sum_{t=1}^{n} |y_t - \ba
## 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** | ~40 ns/bar | Three running sums maintained |
+23 -1
View File
@@ -1,4 +1,4 @@
# RMSE: Root Mean Squared Error
# RMSE: Root Mean Squared Error
> "MSE's more interpretable sibling that speaks the language of your data."
@@ -29,6 +29,28 @@ 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 |
+23 -1
View File
@@ -1,4 +1,4 @@
# RMSLE: Root Mean Squared Logarithmic Error
# RMSLE: Root Mean Squared Logarithmic Error
> "RMSLE: because sometimes your errors need to be measured in decades, not dollars."
@@ -40,6 +40,28 @@ $$\text{RMSLE} \approx |\log(1 + \epsilon)| \approx |\epsilon|$$
## 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** | 28 ns/bar | O(1) with sqrt overhead |
+23 -1
View File
@@ -1,4 +1,4 @@
# RSE: Relative Squared Error
# RSE: Relative Squared Error
> "The squared error version of RAE. RSE and R² are two sides of the same coin: R² = 1 - RSE."
@@ -41,6 +41,28 @@ $$R^2 = 1 - \text{RSE}$$
## 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** | ~40 ns/bar | Three running sums maintained |
+23 -1
View File
@@ -1,4 +1,4 @@
# R²: Coefficient of Determination
# R²: Coefficient of Determination
> "R² tells you how much of the variance in actual values is explained by your predictions. It's the statistician's favorite metric for good reason."
@@ -41,6 +41,28 @@ $$R^2 = 1 - \text{RSE}$$
## 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** | ~40 ns/bar | Three running sums maintained |
+23 -1
View File
@@ -1,4 +1,4 @@
# SMAPE: Symmetric Mean Absolute Percentage Error
# SMAPE: Symmetric Mean Absolute Percentage Error
> "MAPE punishes based on who's right; SMAPE punishes based on how different they are."
@@ -52,6 +52,28 @@ SMAPE is bounded between 0% and 200%:
## 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** | 18 ns/bar | O(1) via running sum |
+23 -1
View File
@@ -1,4 +1,4 @@
# Theil's U: Theil's U Statistic
# Theil's U: Theil's U Statistic
> "The forecast that matters is the one that beats a naive guess."
@@ -86,6 +86,28 @@ TheilU.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
## Performance Profile
### Operation Count (Streaming Mode)
Theil's U statistic: U = sqrt(MSE_forecast) / sqrt(MSE_naive). Requires two running mean-squared-error accumulators.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Forecast MSE update (e^2 + EMA) | 2 | ~5 cy | ~10 cy |
| Naive MSE update (naive_e^2 + EMA) | 2 | ~5 cy | ~10 cy |
| U = sqrt(MSE_f) / sqrt(MSE_n) | 2 | ~15 cy | ~30 cy |
| **Total** | **~6** | — | **~50 cycles** |
O(1) per bar. Two parallel EMA accumulators + ratio with sqrt. ~50 cycles/bar.
### Batch Mode (SIMD Analysis)
| Operation | Vectorizable? | Notes |
| :--- | :---: | :--- |
| Squared error accumulation | Yes | Element-wise squares + reduction |
| sqrt ratio | No | Single scalar at end |
Batch MSE accumulation vectorizable; final ratio is scalar. ~8 cy/bar for squared-error accumulation.
| Metric | Score | Notes |
| :--- | :--- | :--- |
| **Throughput** | ~15 ns/bar | O(1) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# Tukey's Biweight: Robust Loss Function
# Tukey's Biweight: Robust Loss Function
> "When outliers need to be silenced, not just quieted."
@@ -91,6 +91,28 @@ TukeyBiweight.Batch(actualSpan, predictedSpan, outputSpan, period: 20, c: 4.685)
## 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) update complexity |
+23 -1
View File
@@ -1,4 +1,4 @@
# WMAPE: Weighted Mean Absolute Percentage Error
# WMAPE: Weighted Mean Absolute Percentage Error
> "When not all errors are created equal, weight them by what matters."
@@ -78,6 +78,28 @@ Wmape.Batch(actualSpan, predictedSpan, outputSpan, 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** | ~12 ns/bar | O(1) update complexity |