Decomposes a seasonal time series into trend + seasonal + residual components. Classical (moving-average) or STL (Loess-based).
Decomposition separates the systematic structure of a series from the noise. Classical decomposition uses centred moving averages for the trend and per-period means (after detrending) for the seasonal; STL uses Loess smoothing for both, giving a more flexible decomposition that handles changing seasonal patterns.
Three components: trend (long-run movement), seasonal (period-by-period pattern), residual (everything else). Additive decomposition assumes constant seasonal amplitude; multiplicative assumes amplitude grows with trend.
Numeric series + period (e.g. 12 for monthly, 7 for daily-with-weekly-cycle) + decomposition type (additive / multiplicative).
Trend / seasonal / residual arrays + variance share of each.
Residual variance share substantially below 1 ⇒ the series has identifiable structure; close to 1 ⇒ mostly noise.