平滑处理
x = xlsread('examp03_02.xls');%从文件读取数据
price = x(:,4)'; %提取矩阵x的第四列数据,即收盘价数据
figure; %新建一个图形窗口
plot(price,'k','LineWidth',2);%绘制收盘价曲线图,黑色实线,线宽为2
xlabel('观测序号'); ylabel('上海股市日收盘价');%x轴y轴标签
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,标准差0.65)',...
'平滑曲线(窗宽100,标准差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');
数据的标准化变换
对于多元数据,当各变量的量纲和数量级不一致时,往往需要对数据进行变换处理,以消除对量纲和数量级的限制,以便进行后续的统计分析。
极差归一化变换rscore函数[r,xmin,xrange]=rscore(X)
、标准化变换函数zscore函数[Z,mu,siga]=zscore(X)