平滑處理
x = xlsread('examp03_02.xls');%從文件讀取數(shù)據(jù)
price = x(:,4)'; %提取矩陣x的第四列數(shù)據(jù),即收盤價數(shù)據(jù)
figure; %新建一個圖形窗口
plot(price,'k','LineWidth',2);%繪制收盤價曲線圖,黑色實線,線寬為2
xlabel('觀測序號'); ylabel('上海股市日收盤價');%x軸y軸標(biāo)簽
output1 = smoothts(price,'b',30);
output2 = smoothts(price,'b',100);
figure;
plot(price,'.');
hold on
plot(output1,'k','LineWidth',2);
plot(output2,'k-.','LineWidth',2);
xlabel('觀測序號'); ylabel('Box method');
legend('原始散點','平滑曲線(窗寬30)','平滑曲線(窗寬100)','location','northwest');
output3 = smoothts(price,'g',30);
output4 = smoothts(price,'g',100,100);
figure;
plot(price,'.');
hold on
plot(output3,'k','LineWidth',2);
plot(output4,'k-.','LineWidth',2);
xlabel('觀測序號'); ylabel('Gaussian window method');
legend('原始散點','平滑曲線(窗寬30,標(biāo)準(zhǔn)差0.65)',...
'平滑曲線(窗寬100,標(biāo)準(zhǔn)差100)','location','northwest');
output5 = smoothts(price,'e',30);
output6 = smoothts(price,'e',100);
figure;
plot(price,'.');
hold on
plot(output5,'k','LineWidth',2);
plot(output6,'k-.','LineWidth',2);
xlabel('觀測序號'); ylabel('Exponential method');
legend('原始散點','平滑曲線(窗寬30)','平滑曲線(窗寬100)','location','northwest');
數(shù)據(jù)的標(biāo)準(zhǔn)化變換
對于多元數(shù)據(jù),當(dāng)各變量的量綱和數(shù)量級不一致時,往往需要對數(shù)據(jù)進行變換處理,以消除對量綱和數(shù)量級的限制,以便進行后續(xù)的統(tǒng)計分析。
極差歸一化變換rscore函數(shù)[r,xmin,xrange]=rscore(X)、標(biāo)準(zhǔn)化變換函數(shù)zscore函數(shù)[Z,mu,siga]=zscore(X)