# 基于马尔科夫和ARIMA模型的销量预测 Sales Forecast Based on Markov and ARIMA Models

• 全文下载: PDF(1592KB)    PP.711-723   DOI: 10.12677/SA.2019.84081
• 下载量: 283  浏览量: 518

Many merchants are deeply troubled by the problem of filling orders caused by insufficient stock of goods, and the problem of filling orders mainly has two problems: the occupation of cash flow and the problem of inventory. Therefore, effective and reasonable replenishment strategy is an urgent problem for merchants. Based on the sales data of business over the years, and on the basis of data preprocessing, this paper studies the sales volume of a business from several aspects, such as model hypothesis, model establishment and solution. According to the establishment of ARIMA model, and according to ARIMA model, the sales volume in the next few days is fitted and predicted, and then the results are tested by Markov model, which provides a theoretical basis for the replenishment and inventory of the merchant.

1. 引言

2. 数据来源与模型假设

3. ARIMA预测模型建立与求解

1) 数据预处理及平稳性检验

Figure 1. Sales sequence diagram of a selected article number

Figure 2. First-order difference processing diagram of sales volume data of a certain article number

2) 模型识别与定阶

Figure 3. ACF diagram and APCF diagram after sequence difference

Table 1. Test results of fitting model for each parameter in ARIMA model

3) ARIMA模型预测

$\Delta {x}_{t}=0.033\Delta {x}_{t-1}+{\epsilon }_{t}-0.562{\epsilon }_{t}$

Figure 4. Model fitting diagram corresponding to ARIMA model parameters (3, 1, 3)

Figure 5. ARIMA (3, 1, 3) model fitting results

4. 马尔可夫预测模型的建立

1) 马氏性检验

Figure 6. Sales volume forecast by ARIMA model for the next 5 days

Table 2. Sales grade status division

${f}_{1}=\left(\begin{array}{ccccc}190& 7& 4& 1& 2\\ 9& 8& 4& 2& 1\\ 3& 6& 3& 1& 2\\ 1& 1& 3& 0& 3\\ 2& 2& 1& 4& 12\end{array}\right)$

${p}_{1}=\left(\begin{array}{ccccc}0.9314& 0.0343& 0.0196& 0.0049& 0.0098\\ 0.3750& 0.3333& 0.1667& 0.0833& 0.0417\\ 0.2000& 0.4000& 0.2000& 0.0667& 0.1333\\ 0.1250& 0.1250& 0.3750& 0& 0.3750\\ 0.0952& 0.0952& 0.0476& 0.1905& 0.5714\end{array}\right)$

${p}_{2}=\left(\begin{array}{ccccc}0.9310& 0.0394& 0.0099& 0.0099& 0.0099\\ 0.4583& 0.2083& 0.2083& 0.0417& 0.0833\\ 0.1333& 0.2667& 0.2000& 0.1333& 0.2667\\ 0& 0.7500& 0& 0.1250& 0.1250\\ 0.1429& 0.0476& 0.2381& 0.0476& 0.5283\end{array}\right)$

${p}_{3}=\left(\begin{array}{ccccc}0.9163& 0.0591& 0.0148& 0.0049& 0.0049\\ 0.4167& 0.2500& 0.1250& 0.0833& 0.1250\\ 0.2143& 0.0714& 0.2143& 0.2143& 0.2857\\ 0.2500& 0.1250& 0.3700& 0& 0.2500\\ 0.1905& 0.1905& 0.0952& 0.0476& 0.4762\end{array}\right)$

${p}_{4}=\left(\begin{array}{ccccc}0.9261& 0.0493& 0.0148& 0.0049& 0.0049\\ 0.4167& 0.2917& 0.0833& 0.1250& 0.0833\\ 0.2143& 0.0714& 0.2857& 0.0714& 0.3751\\ 0.2500& 0.1250& 0.2500& 0.1250& 0.2500\\ 0.1000& 0.2000& 0.1500& 0.0500& 0.5000\end{array}\right)$

${p}_{5}=\left(\begin{array}{ccccc}0.9212& 0.0493& 0.0246& 0.0049& 0\\ 0.3750& 0.2500& 0.1667& 0.0833& 0.1250\\ 0.2857& 0.2143& 0.1429& 0.0714& 0.2857\\ 0.2500& 0.1250& 0.1250& 0& 0.5000\\ 0.1579& 0.1579& 0.0526& 0.1579& 0.4737\end{array}\right)$

2) 马尔可夫模型预测及分析

${r}_{s}=\frac{{\sum }_{t=1}^{n/s}\left({X}_{t}-\stackrel{¯}{X}\right)}{{\sum }_{t=1}^{n/s}{\left({X}_{t}-\stackrel{¯}{X}\right)}^{2}}$

${\omega }_{s}=\frac{|{r}_{s}|}{{\sum }_{t=1}^{l}|{r}_{s}|}$

Table 3. 2018/12/08 sales grade forecast

5. 模型检验

Figure 7. ACF and PACF diagrams of model residuals of ARIMA (3, 1, 3)

Figure 8. Prediction fitting effect of ARIMA (3, 1, 3) model

6. 结论

clc

clear

E=a(:,4)';

fori=1:5

forj=1:5

a1=0;

a2=0;

a3=0;

a4=0;

a5=0;

forn=1:272

ifE(n)==i

ifE(n+1)==j

a1=a1+1;

end

end

f1(i,j)=a1;

end

forn=1:271

ifE(n)==i

ifE(n+2)==j

a2=a2+1;

end

end

f2(i,j)=a2;

end

forn=1:270

ifE(n)==i

ifE(n+3)==j

a3=a3+1;

end

end

f3(i,j)=a3;

end

forn=1:269

ifE(n)==i

ifE(n+4)==j

a4=a4+1;

end

end

f4(i,j)=a4;

end

forn=1:268

ifE(n)==i

ifE(n+5)==j

a5=a5+1;

end

end

f5(i,j)=a5;

end

end

end

f1

fori=1:5

forj=1:5

p1(i,j)=f1(i,j)/sum(f1(i,:));

p2(i,j)=f2(i,j)/sum(f2(i,:));

p3(i,j)=f3(i,j)/sum(f3(i,:));

p4(i,j)=f4(i,j)/sum(f4(i,:));

p5(i,j)=f5(i,j)/sum(f5(i,:));

end

end

p1,p2,p3,p4,p5

forn=1:5

a1=0;

a2=0;

fori=1:5

a1=a1+f1(i,n);

forj=1:5

a2=a2+f1(i,j);

end

end

S(n)=a1/a2;

end

S

fori=1:5

forj=1:5

x_tjl(i,j)=2*f1(i,j)*abs(log(p1(i,j))-log(S(j)));

end

end

x_tjl(4,4)=0

x_tjl=sum(x_tjl(:));

x_bzl=32;

ifx_tjl>x_bzl

disp('该序列符合马氏性')

elsex_tjl

disp('不能对该序列用马尔科夫模型')

end

E_jun=sum(E(1,:))/length(E);

forn=1:5

a1=0;

a2=0;

fort=1:(length(E)-n)

a1=a1+(E(t)-E_jun)*(E(t+n)-E_jun);

a2=a2+(E(t)-E_jun)^2;

end

r(n)=a1/a2;

end

r

forn=1:5

a3=0;

fort=1:5

a3=a3+r(t);

end

w(n)=r(n)/a3;

end

w

k=325

K(1,:)=p5(E(k-5),:);

K(2,:)=p4(E(k-4),:);

K(3,:)=p3(E(k-3),:);

K(4,:)=p2(E(k-2),:);

K(5,:)=p1(E(k-1),:);

K

fori=1:5

a1=0;

forj=1:5

a1=a1+K(j,i)*w(6-j);

end

P(i)=a1;

end

P

 [1] 葛娜, 孙连英, 赵平, 万莹. 基于ARIMA时间序列模型的销售量预测分析[J]. 北京联合大学学报, 2018(8): 28-33. [2] 魏杰, 张璇, 王柳, 汪丽萍. 基于灰色预测和ARIMA模型的疾病分析与预测[J]. 数理医药学杂志, 2018, 31(12): 1739-1742. [3] 徐梦茹, 王学明. 马尔可夫与ARIMA组合模型对地区降雨量的预测研究[J]. 计算机应用与软件, 2019, 36(3): 34-37. [4] 董大勇, 刘珂言. 基于ARIMA模型的工业品出厂价格指数预测与分析[J]. 统计与决策, 2016(1): 179-181. [5] 数学建模之马尔可夫预测[J/OL]. https://wenku.baidu.com/view/4bc708f66e1aff00bed5b9f3f90f76c660374c53.html, 2018-02-04.