The Croston method is a statistical method used to predict intermittent demand. It is suitable for products or services with unstable and irregular demand, such as spare parts, consulting services, medical supplies, etc., where the demand is highly uncertain. The advantages of this method are that it is simple and easy to use, fast in calculation, and has a wide range of applications. At the same time, it can avoid some defects in traditional prediction methods. By analyzing historical data of intermittent demand, the Croston method can effectively capture the changing trends and intervals of demand and make accurate demand forecasts based on this information. Therefore, the Croston method has important application value in managing and planning intermittent demand.
The basic principle of Croston's method is to decompose the intermittent demand sequence into two parts: the time interval between demand occurrence and the demand quantity. This decomposition process is based on two basic assumptions: first, the time interval between demand occurrence and demand quantity are independent of each other; second, the distribution of demand quantity can be approximated as a binomial distribution. By analyzing and forecasting these two parts, the characteristics and changes of intermittent demand can be better understood and predicted.
The Croston method uses two exponential smoothing models to predict time intervals and demand quantities. The forecast value of the time interval is called the interval forecast value, and the forecast value of the demand is called the demand forecast value. Then, by multiplying the two predicted values, the overall predicted value is obtained. Determining the parameters of the two exponential smoothing models is the key to Croston's method.
In practical applications, the Croston method can be carried out through the following steps:
First, we need to calculate the interval forecast value and the demand forecast value . Interval forecasts can be calculated using simple exponential smoothing, while demand forecasts can be calculated using the formulas in Croston's method.
The second step is to calculate the overall predicted value. Multiply the interval forecast and the demand forecast to get the overall forecast.
The third step is to evaluate the accuracy of the prediction results. The accuracy of forecast results can be evaluated using mean absolute error (MAE) or root mean square error (RMSE). At the same time, error analysis can also be performed to find deviations and anomalies in the prediction results.
It should be noted that the Croston method may not be applicable to products or services with small demand or long demand intervals, because in these cases, changes in demand and time intervals may will be affected by greater randomness. In addition, the Croston method also needs parameter adjustment based on actual conditions to improve prediction accuracy.
The core idea of Croston's method is to predict future demand and demand occurrence time by smoothing the average of two sequences. Specifically, this method expresses the demand time series and demand quantity sequence respectively in the following form:
y_t=\begin{cases} 1&\text{if demand occurs at time}t\ 0&\text{otherwise} \end{cases} p_t=\begin{cases} d_t&\text{if demand occurs at time}t\ 0&\text{otherwise} \end{cases}
where y_t represents whether there is demand at time t, and p_t represents the demand at time t (if there is demand if it happens). Next, the method performs smoothing by calculating the average of y_t and p_t. Specifically, the average calculation formula is as follows:
\begin{aligned} \bar{y}_t&=\alpha y_t+(1-\alpha)\bar{y}_{t-1}\ \bar{p}_t&=\alpha p_t+(1-\alpha)\bar{p}_{t-1} \end{aligned}
where \alpha is the smoothing coefficient, usually between 0.1 and 0.3. The method then uses the smoothed average to make demand forecasts. Specifically, the formula for predicting the next demand occurrence time and demand quantity by this method is as follows:
\begin{aligned} \hat{y}_{t+1}&=\frac{1}{\bar{y}_t+\frac{1}{1-\alpha}}\ \hat{p}_{t+1}&=\frac{\bar{p}_t}{\bar{y}_t+\frac{1}{1-\alpha}} \end{aligned}
The Croston method also includes some correction terms to reduce the bias in demand forecasting. Specifically, the method includes corrections to the demand time series and demand quantity series, as well as corrections to the smoothing coefficient.
The following is a Python code example that uses the Croston method for intermittent demand forecasting:
import pandas as pd import numpy as np def croston(y, forecast_len, alpha=0.2, init=None): """ Croston方法预测间歇性需求 参数: y:需求数据 forecast_len:预测长度 alpha:平滑系数,默认为0.2 init:初始值,默认为None 返回: 预测结果 """ # 初始化 y = np.asarray(y) n = len(y) if init is None: # 如果没有指定初始值,则使用第一个非零值作为初始值 init = np.nonzero(y)[0][0] p = np.zeros(n) y_hat = np.zeros(n+forecast_len) p_hat = np.zeros(n+forecast_len) y_hat[init] = y[init] p_hat[init] = y[init] # 平滑 for i in range(init+1, n): if y[i] > 0: # 如果有需求发生 y_hat[i] = alpha + (1 - alpha)*y[i-1] p_hat[i] = alpha*y[i] + (1 -alpha)*p[i-1] else: # 如果没有需求发生 y_hat[i] = (1 - alpha)*y_hat[i-1] p_hat[i] = (1 - alpha)*p_hat[i-1] # 预测 for i in range(n, n+forecast_len): y_hat[i] = (1 - alpha)*y_hat[i-1] p_hat[i] = (1 - alpha)*p_hat[i-1] return p_hat[-forecast_len:] # 示例 demand = [0, 0, 5, 0, 0, 7, 0, 0, 9, 0, 0, 6, 0] forecast_len = 5 result = croston(demand, forecast_len) print(result)
In the above code, we use the Croston method to predict an intermittent demand The data were predicted. This data contains the demand situation at 13 time points, of which demand occurs at 5 time points, and the demand at the remaining time points is 0. The forecast results include demand for the next five time points. In the code, we set a smoothing coefficient to 0.2, using the first non-zero value as the initial value. The prediction results are [1.677, 1.342, 1.074, 0.859, 0.684], indicating that the demand at the next five time points are 1.677, 1.342, 1.074, 0.859 and 0.684 respectively.
The above is the detailed content of Application of Croston method in forecasting intermittent demand. For more information, please follow other related articles on the PHP Chinese website!