RollingMedian / Computation Layer
Calculate the rolling (moving) median over a sliding window. Similar to pandas.rolling().median() or R's rollmedian(). More robust to outliers than mean.
Mathematical form: For each window, find value where:
Common applications:
- Robust trend detection
- Outlier-resistant smoothing
- Image processing (median filtering)
- Economic indicators (house prices)
- Noise reduction in sensors
- Clinical data analysis
- Financial risk assessment
Note: More computationally intensive than mean but better handles outliers.
Select
columnThe numeric column to compute rolling medians for. Ideal for:
- Price data with outliers
- Sensor data with noise
- Economic indicators
- Population statistics
- Quality measurements
Especially useful when mean is skewed by extreme values.
WindowSize
u32Number of observations in each sliding window. Common choices:
- 5: Weekly median (business days)
- 7: Weekly median (calendar days)
- 30: Monthly median
- 90: Quarterly median Odd window sizes provide single middle value; even sizes average two middle values.
Weights
[f64, ...]Optional weights for window values. Must match window size if provided. Note:
- Weights affect value selection process
- Changes interpretation of median
- Less common than weighted means
Consider carefully whether weighted median meets analytical needs.
MinPeriods
oneofRequire complete windows for median calculation. Ensures statistical validity by only computing when all values in window are available. Critical for accurate central tendency measurement in presence of outliers.
Center
boolWindow label position. When true
, aligns to window center; when false
, to end. Consider:
true
: Better for historical analysis and pattern identificationfalse
: Better for real-time monitoring and immediate decision making
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.