Spare parts and slow-moving products sell in occasional bursts separated by many zero periods. Croston's method forecasts such a series by smoothing the size of each non-zero demand and the gap between demands separately.
Implement croston(y, alpha, variant="croston").
Inputs. y: 1-D array of non-negative demands of length . alpha: smoothing constant in . variant: "croston" or "sba"; anything else raises ValueError.
State. (smoothed demand size) and (smoothed interval), both undefined until the first non-zero demand.
Forecast. for "croston" and for "sba".
Output. A list of values. Entry is the forecast for period made with , so entry is the out-of-sample forecast. An entry is None while no non-zero demand has been seen. Round values to 4 decimals.