Split a series into trend + seasonal + residual, the classical additive decomposition (what statsmodels.seasonal_decompose does).
Implement decompose(y, period) returning (trend, seasonal, resid), three arrays the same length as y:
period values centred on each point. For an even period, use a "2 × period" average: weights [0.5, 1, …, 1, 0.5] / period over period + 1 points. Positions without a full window are NaN.i % period), average the detrended values y - trend (ignoring NaNs). Subtract the mean of those period averages so they sum to zero, then tile across the series.y - trend - seasonal (NaN where the trend is NaN).Also implement seasonal_strength(seasonal, resid): over positions where the residual isn't NaN.