用小波神经网络来对时间序列进行预测

用小波神经网络来对时间序列进行预测
用小波神经网络来对时间序列进行预测

/* Note:Your choice is C IDE */

#include"stdio.h"

void main()

{

}/*用小波神经网络来对时间序列进行预测 */

/*%File name : nprogram.m

%Description : This file reads the data from

%its source into their respective matrices prior to

% performing wavelet decomposition.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Clear command screen and variables */

clc;

clear;

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% user desired resolution level (Tested: resolution = 2 is best)*/

level = menu('Enter desired resolution level: ', '1',...

'2 (Select this for testing)', '3', '4');

switch level

case 1, resolution = 1;

case 2, resolution = 2;

case 3, resolution = 3;

case 4, resolution = 4;

end

msg = ['Resolution level to be used is ', num2str(resolution)];

disp(msg);

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% user desired amount of data to use */

data = menu('Choose amount of data to use: ', '1 day', '2 days', '3 days', '4 days',...

'5 days', '6 days', '1 week (Select this for testing)'); switch data

case 1, dataPoints = 48; /*%1 day = 48 points */

case 2, dataPoints = 96; /* %2 days = 96 points */

case 3, dataPoints = 144; /*%3 days = 144 points */

case 4, dataPoints = 192; /*%4 days = 192 points */

case 5, dataPoints = 240; /* %5 days = 240 points */

case 6, dataPoints = 288; /* %6 days = 288 points */

case 7, dataPoints = 336; /*%1 weeks = 336 points */

end

msg = ['No. of data points to be used is ', num2str(dataPoints)];

disp(msg);

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Menu for data set selection */

select = menu('Use QLD data of: ', 'Jan02',...

'Feb02', 'Mar02 (Select this for testing)', 'Apr02', 'May02');

switch select

case 1, demandFile ='DATA200601_QLD1';

case 2, demandFile ='DATA200602_QLD1';

case 3, demandFile ='DATA200603_QLD1';

case 4, demandFile ='DATA200604_QLD1';

case 5, demandFile ='DATA200605_QLD1';

end

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Reading the historical DEMAND data into tDemandArray */ selectedDemandFile=[demandFile,'.csv'];

[regionArray, sDateArray, tDemandArray, rrpArray, pTypeArray] ...

= textread(selectedDemandFile, '%s %q %f %f %s', 'headerlines', 1,

'delimiter', ',');

/*%Display no. of points in the selected time series demand data */ [demandDataPoints, y] = size(tDemandArray);

msg = ['The no. of points in the selected Demand data is ',

num2str(demandDataPoints)];

disp(msg);

/*%Decompose historical demand data signal */

[dD, l] = swtmat(tDemandArray, resolution, 'db2');

approx = dD(resolution, :);

/*%Plot the original demand data signal */

figure (1);

subplot(resolution + 2, 1, 1); plot(tDemandArray(1: dataPoints))

legend('Demand original');

title('QLD Demand Data Signal');

/*%Plot the approximation demand data signal */

for i = 1 : resolution

subplot(resolution + 2, 1, i + 1); plot(approx(1: dataPoints)) legend('Demand Approximation');

end

/*%After displaying approximation signal, display detail x */

for i = 1: resolution

if( i > 1 )

detail(i, :) = dD(i-1, :)- dD(i, :);

else

detail(i, :) = tDemandArray' - dD(1, :);

end

if i == 1

subplot(resolution + 2, 1, resolution - i + 3);

plot(detail(i, 1: dataPoints))

legendName = ['Demand Detail ', num2str(i)];

legend(legendName);

else

subplot(resolution + 2, 1, resolution - i + 3);

plot(detail(i, 1: dataPoints))

legendName = ['Demand Detail ', num2str(i)];

legend(legendName);

end

i = i + 1;

end

/*%Normalising approximation demand data */

maxDemand = max(approx'); %Find largest component

normDemand = approx ./ maxDemand; /*%Right divison */

maxDemandDetail = [ ];

normDemandDetail = [, ];

detail = detail + 4000;

for i = 1: resolution

maxDemandDetail(i) = max(detail(i, :));

normDemandDetail(i, :) = detail(i, :) ./maxDemandDetail(i);

end

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Reading the historical historical PRICE data into rrpArray */ selectedPriceFile = [demandFile, '.csv'];

[regionArray, sDateArray, tDemandArray, rrpArray, pTypeArray] ...

= textread(selectedDemandFile, '%s %q %f %f %s', 'headerlines', 1,

'delimiter', ',');

/*%Display no. of points in Price data */

[noOfDataPoints, y] = size(rrpArray);

msg =['The no. of points in Price data data is ', num2str(noOfDataPoints)]; disp(msg);

/*%Decompose historical Price data signal */

[dP, l] = swtmat(rrpArray, resolution, 'db2');

approxP = dP(resolution, :);

/*%Plot the original Price data signal */

figure (2);

subplot(resolution + 3, 1, 1); plot(rrpArray(2: dataPoints))

legend('Price original');

title('Price Data Signal');

/*%Plot the approximation Price data signal */

for i = 1 : resolution

subplot(resolution + 3, 1, i + 1); plot(approxP(2: dataPoints))

legend('Price Approximation');

end

/*%After displaying approximation signal, display detail x */

for i = 1: resolution

if( i > 1 )

detailP(i, :) = dP(i-1, :)- dP(i, :);

else

detailP(i, :) = rrpArray' - dP(1, :);

end

if i == 1

[B,A]=butter(1,0.65,'low');

result =filter(B,A, detailP(i, 1: dataPoints));

subplot(resolution + 3, 1, resolution - i + 4);plot(result(i, 2: dataPoints))

legendName = ['low pass filter', num2str(i)];

legend(legendName);

subplot(resolution + 3, 1, resolution - i + 3); plot(detailP(i, 2: dataPoints))

legendName = ['Price Detail ', num2str(i)];

legend(legendName);

else

subplot(resolution + 3, 1, resolution - i + 3); plot(detailP(i, 2: dataPoints))

legendName = ['Price Detail ', num2str(i)];

legend(legendName);

end

i = i + 1;

end

/*%Normalising approximation Price data */

maxPrice = max(approxP'); %Find largest component

normPrice = approxP ./ maxPrice; /*%Right divison */

maxPriceDetail = [ ];

normPriceDetail = [, ];

detailP = detailP + 40;

for i = 1: resolution

maxPriceDetail(i) = max(detailP(i, :));

normPriceDetail(i, :) = detailP(i, :) ./maxPriceDetail(i);

end

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Function here allows repetitive options to,

% 1) Create new NNs, 2) Retrain the existing NNs,

% 3) Perform load demand forecasting and 4) Quit session */

while (1)

choice = menu('Please select one of the following options: ',...

'Create new Neural Networks',...

'Perform FORECASTING of load demand', 'QUIT session...');

switch choice

case 1, scheme ='1';

case 2, scheme ='2';

case 3, scheme ='3';

case 4, scheme ='4';

end

/* %If scheme is 'c', call to create new NNs, train them then perform forecast */

if(scheme =='1')

nCreate;

end

/*%If scheme is 'r', call to retrain the existing NNs */

if(scheme =='2')

nRetrain;

end

/* %If scheme is 'f', call to load the existing NN model */

if(scheme =='3')

nForecast;

end

/* %If scheme is 'e', verifies and quit session if 'yes' is selected else continue */

if(scheme =='4')

button = questdlg('Quit session?', 'Exit

Dialog','Yes','No','No');

switch button

case'Yes', disp(' ');

disp('Session has ended!!');

disp(' ');

break;

case'No', quit cancel;

end

end

end

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%File name : ncreate.m

%Description : This file prepares the input & output data for the NNs. It creates then trains the

% NNs to mature them. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Clear command screen and set target demand ouput to start at point 2 */ clc;

targetStartAt = 2;

disp('Program will now Create a Neural Network for training and forecasting...');

disp(' ');

disp('To capture the pattern of the signal, the model is ')

disp('set to accept dataPoints x 2 sets of training examples; ');

disp('1 set of demand + 1 sets of price. ');

disp(' ');

disp('The normalised demand data , is to be taken as the ')

disp('output value for the first iteration of training examples. '); disp(' ');

disp('Press ENTER key to continue...');

pause;

/*%Clear command screen then prompt for no. of training cycles

%For current program, 1 cycle = user set no. of iterations (ie: dataPoints) */

clc;

cycle = input('Input the number of training cycles: ');

numOfTimes = resolution + 1;

/*%Creating and training the NNs for the respective

%demand and price coefficient signals */

for x = 1: numOfTimes

/*%Clearing variables */

clear targetDemand;

clear inputs;

clear output;

clc;

if(x == 1)

neuralNetwork = ['Neural network settings for approximation level ',

num2str(resolution)];

else

neuralNetwork = ['Neural network settings for detail level ', num2str(x - 1)];

end

disp(neuralNetwork);

disp(' ');

/*%Set no. of input nodes and hidden neurons for the

%respective demand and price coefficient signal */

numOfInputs = 2;

inputValue = ['Number of neural network INPUT units is set at ', num2str(numOfInputs)];

disp(inputValue);

disp(' ');

numOfOutput = 1;

outValue = ['Output is set to ', num2str(numOfOutput)];

disp(outValue);

disp(' ');

numOfHiddens =input('Enter the no. of HIDDEN units for the NN hidden : ');

hiddenValue = ['Number of neural network HIDDEN units is set at ', num2str(numOfHiddens)];

disp(hiddenValue);

disp(' ');

/*%Setting no. of training examples */

trainingLength = dataPoints;

/* %Set target outputs of the training examples */

if(x == 1)

targetDemand = normDemand(targetStartAt: 1 + trainingLength);

else

targetDemand = normDemandDetail(x - 1, targetStartAt: 1 + trainingLength);

end

/* %Preparing training examples

%Setting training i/ps to be 2 with user defined no. of iterations (dataPoints) */

y = 0;

while y < trainingLength

if(x == 1)

inputs(1, y + 1) = normDemand(y + 1);

inputs(2, y + 1) = normPrice(y + 1);

else

inputs(1, y + 1) = normDemandDetail(x - 1, y + 1);

inputs(2, y + 1) = normPriceDetail(x - 1, y + 1);

end

output(y + 1, :) = targetDemand(y + 1);

y = y + 1;

end

inputs = (inputs');

/*%Setting no. of training cycles */

[ni, np] = size(targetDemand); %<== [ni, np] tells the NN how long

is 1 cycle;

size(targetDemand)

clear nn;

/*%Create new neural network for respective coefficient signal

%NET = MLP(NIN, NHIDDEN, NOUT, FUNC) */

nn = mlp(numOfInputs, numOfHiddens, numOfOutput, 'linear');

/*%NN options */

options = zeros(1, 18);

options(1) = 1; %Provides display of error values

options(14) = cycle * ni * np;

/* %Training the neural network

%netopt(net, options, x, t, alg); */

nn = netopt(nn, options, inputs, output, 'scg');

/* %Save the neural network */

filename = ['nn', num2str(x)];

save(filename, 'nn');

disp(' ');

msg = ['Neural network successfully CreateD and saved as => ', filename];

disp(msg);

if(x < 3)

disp(' ');

disp('Press ENTER key to continue training the next NN...');

else

disp(' ');

disp('Model is now ready to forecast!!');

disp(' ');

disp('Press ENTER key to continue...');

end

pause;

end

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%File name : nforecast.m

%Description : This file loads the trained NNs for load forcasting

and %recombines the predicted

% outputs from the NNs to form the final predicted load series.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Clear command screen and variables */

clc;

clear forecastResult;

clear actualDemand;

clear predicted;

clear actualWithPredicted;

disp('Neural networks loaded, performing electricity demand forecast...'); disp(' ');

pointsAhead = input('Enter no. of points to predict (should be < 336): ');

numOfTimes = resolution + 1;

/*%Predict coefficient signals using respective NNs */

for x = 1 : numOfTimes

/*%Loading NN */

filename = ['nn', num2str(x)];

clear nn

load(filename);

clear in;

numOfInputs = nn.nin;

y = 0;

/* %Preparing details to forecast */

while y < pointsAhead

if(x == 1)

propData(1, y + 1) = normDemand(y + 1);

propData(2, y + 1) = normPrice(y + 1);

else

propData(1, y + 1) = normDemandDetail(x - 1, y + 1);

propData(2, y + 1) = normPriceDetail(x - 1, y + 1);

end

y = y + 1;

end

if(x == 1)

forecast = mlpfwd(nn, propData') * maxDemand;

else

forecast = mlpfwd(nn, propData') * maxDemandDetail(x - 1) - 4000;

end

forecastResult(x, :) = forecast';

end

/*%For debugging

% forecastResult */

actualDemand = tDemandArray(2: 1 + pointsAhead);

predicted = sum(forecastResult, 1)';

/*%Calculating Mean Absolute Error */

AbsError = abs(actualDemand - predicted(1: pointsAhead)) ./ actualDemand; msg = ['Mean Absolute Error = ', num2str(mean(AbsError(1: pointsAhead))), ' !!'];

disp(' ');

disp(msg);

/*%Plot actual time series against predicted result */

figure(3)

actualWithPredicted(:, 1) = actualDemand;

actualWithPredicted(:, 2) = predicted(1: pointsAhead);

plot(actualWithPredicted);

graph = ['Mean Absolute Error = ', num2str(mean(AbsError))];

title(graph);

legend('Actual', 'Forecasted');

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%File name : nretrain.m

%Description : This file loads the existing NNs and trains them again. */ clc;

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Prompt for the starting point for training */

disp('Program will now RETRAIN the Neural Networks ')

disp('with the SAME intial data series again...');

disp(' ');

disp('To capture the pattern of the signal, the model is ')

disp('set to accept dataPoints x 2 sets of training examples; ');

disp('1 set of demand + 1 sets of price. ');

disp(' ');

disp('The normalised demand data , is to be taken as the ')

disp('output value for the first iteration of training examples. '); disp(' ');

msg = ['Data points to be used for reTraining the NNs is from 1 to ',... num2str(dataPoints)];

disp(msg);

disp(' ');

disp('Press ENTER key to continue...');

pause;

/*%Clear command screen */

clc;

/*%Prompt for no. of training cycles

%For current program, 1 cycle = user set no. of iterations (ie: dataPoints) */

cycle = input('Input number of cycles to retrain the NNs: ');

numOfTimes = resolution + 1;

/*%Loading existing NNs for training */

for x = 1: numOfTimes

/*%Re-initialising variables */

clear targetDemand;

clear inputs;

clear output;

clc;

/*%Loading NN for the respective demand and temperature coefficient signals */

filename = ['nn', num2str(x)];

clear nn

load(filename);

/*%Getting the size of NN*/

numOfInputs = nn.nin;

numOfHiddens = nn.nhidden;

numOfOutput = 1;

/*%Setting length of reTraining examples and target outputs */

reTrainLength = dataPoints;

targetLength = reTrainLength;

targetStartAt = 2;

/*%Set target outputs of the training examples */

if(x == 1)

targetDemand = normDemand(targetStartAt: 1 + targetLength);

else

targetDemand = normDemandDetail(x - 1, targetStartAt: 1 + targetLength);

end

/* %Preparing training examples

%Setting training i/ps to be 2 with user set no. of iterations (dataPoints)*/

y = 0;

while y < reTrainLength

if(x == 1)

inputs(1, y + 1) = normDemand(y + 1);

inputs(2, y + 1) = normPrice(y + 1);

else

inputs(1, y + 1) = normDemandDetail(x - 1, y + 1);

inputs(2, y + 1) = normPriceDetail(x - 1, y + 1);

end

output(y + 1, :) = targetDemand(y + 1);

y = y + 1;

end

inputs = (inputs');

/*%Setting no. of training cycles */

[ni, np] =size(targetDemand); /*% <== [ni, np] tells the NN how long is 1 cycle; */

size(targetDemand) /* %With

reference to line 106 */

/*%NN options */

options = zeros(1, 18);

options(1) = 1; %Provides display of error values

options(14) = cycle * ni * np;

/*%Training the neural network

%netopt(net, options, x, t, alg); */

nn = netopt(nn, options, inputs, output, 'scg');

/*%Save the neural network */

filename = ['nn', num2str(x)];

save(filename, 'nn');

disp(' ');

msg =['Neural network => ', filename, ' <= successfully RETRAINED and saved!! '];

disp(msg);

if(x < 3)

disp(' ');

disp('Press ENTER key to continue training the next NN...');

else

disp(' ');

disp('Model is now ready to forecast again!!');

disp(' ');

disp('Press ENTER key to continue...');

end

pause;

end

小波神经网络的时间序列预测短时交通流量预测.doc

%% 清空环境变量 clc clear %% 网络参数配置 load traffic_flux input output input_test output_test M=size(input,2); %输入节点个数 N=size(output,2); %输出节点个数 n=6; %隐形节点个数 lr1=0.01; %学习概率 lr2=0.001; %学习概率 maxgen=100; %迭代次数 %权值初始化 Wjk=randn(n,M);Wjk_1=Wjk;Wjk_2=Wjk_1; Wij=randn(N,n);Wij_1=Wij;Wij_2=Wij_1; a=randn(1,n);a_1=a;a_2=a_1; b=randn(1,n);b_1=b;b_2=b_1; %节点初始化 y=zeros(1,N); net=zeros(1,n); net_ab=zeros(1,n); %权值学习增量初始化 d_Wjk=zeros(n,M); d_Wij=zeros(N,n); d_a=zeros(1,n);

d_b=zeros(1,n); %% 输入输出数据归一化 [inputn,inputps]=mapminmax(input'); [outputn,outputps]=mapminmax(output'); inputn=inputn'; outputn=outputn'; %% 网络训练 for i=1:maxgen %误差累计 error(i)=0; % 循环训练 for kk=1:size(input,1) x=inputn(kk,:); yqw=outputn(kk,:); for j=1:n for k=1:M net(j)=net(j)+Wjk(j,k)*x(k); net_ab(j)=(net(j)-b(j))/a(j); end temp=mymorlet(net_ab(j)); for k=1:N y=y+Wij(k,j)*temp; %小波函数 end end

(完整版)小波神经网络的时间预测

基于小波神经网络的短时交通流预测 摘要 将小波神经网络的时间序列预测理论应用于短时交通流量的预测。通过小波分解与重构获取交通流量数据中的低频近似部分和高频随机部分, 然后在分析各种模型的优、劣的基础上, 选取较有效的模型或模型结合方式, 建立了交通流量预测模型。最后, 利用实测交通流量数据对模型仿真, 结果表明该模型可以有效地提高短时交通流量预测的精度。 关键词: 小波变换 交通流预测 神经网络 1.背景 众所周知, 道路交通系统是一个有人参与的、时变的、复杂的非线性大系统, 它的显著特点之一就是具有高度的不确定性(人为的和自然的影响)。这种不确定性给短时交通流量预测带来了极大的困难。这也就是短时交通流量预测相对于中长期预测更复杂的原因所在。在交通流量预测方面,小波分析不是一个完全陌生的工具,但是仍然处于探索性的应用阶段。实际上,这种方法在计算机网络的流量的预测中有着广泛的应用。与计算机网络一样,车流也表现出复杂的习性。所以可以把它的应用推广类比到交通流量的预测中来。小波分析有着与生俱来的解决非稳定时间序列的能力, 所以常常被单独用来解决常规时间序列模型中的问题。 2.小波理论 小波分析是针对傅里叶变换的不足发展而来的,傅里叶变换是信号处理领域里最为广泛的一种分析手段,然而他有一个严重的不足,就是变换抛弃了时间信息,变换结果无法判断某个信号发生的时间。小波是一种长度有限,平均值为0的波形,它的特点包括: (1)时域都具有紧支集或近似紧支集; (2)直流分量为0; 小波变换是指把某一基本小波函数ψ(t)平移b 后,再在不同尺度a 下与待分析的信号x(t)做内积。 dt a b t t x a b a WT x )()(1),(-=?*ψ??==?*)(),()()(,,t t x dt t t x b a b a ψψ (2 — 1) 等效的时域表达式为 dt a b x a b a WT x ωωψωj e )()(1),(-=?* a > 0 (2 — 2) 3.小波神经网络 小波神经网络是小波分析理论与神经网络理论相结合的产物,把小波基函数作为隐含层节点的传递函数,信号前向传播的同时误差反向传播的神经网络。 图一中1x ,2x ,....k x 是小波神经网络的输入参数,1y ,2y ....,m y 是小波神经网络的预测输出。

小波神经网络程序

这是一个小波神经网络程序,作者judyever %参考<青岛海洋大学学报> 2001年第1期一种基于BP算法学习的小波神经网络%% %step1--------网络初始化------------------------------------------- clc; clear all; %设定期望的误差最小值 err_goal=0.001; %设定最大循环次数 max_epoch=50; %设定修正权值的学习速率0.01-0.7 lr=0.7; epoch=0; x=0:0.01:0.3;%输入时间序列 d=sin(8*pi*x)+sin(16*pi*x);%目标输出序列 M=size(x,2);%输入节点的个数 N=M;%输出节点的个数 n=10;%隐形节点的个数 %这个地方需要改进,由于实际上隐形节点的个数可以通过小波的时频分析确定 Wjk=randn(n,M); Wij=randn(N,n); % a=randn(1,n); a=1:1:n; b=randn(1,n); % stepa=0.2*(x(M)-x(1)); % a=stepa(n-1)+stepa; % step=(x(M)-x(1))/n; % b=x(1)+step:step:x(1)+n*step; % y=zeros(1,N);%输出节点初始化 y=zeros(1,N);%输出节点初始化 net=zeros(1,n);%隐形节点初始化 net_ab=zeros(1,n);%隐形节点初始化 %step2--------对网络进行训练------------------------------------------- for i=1:1:N for j=1:1:n for k=1:1:M net(j)=net(j)+Wjk(j,k)*x(k); net_ab(j)=(net(j)-b(j))/a(j); end y(i)=y(i)+Wij(i,j)*mymorlet(net_ab(j)); %mymorlet是judyever编写的小波函数,以后可以扩展成输入不同的小波名字即可 % y(i)=mysigmoid(2,y(i)); end

基于BP神经网络的时序预测及其应用

目录 摘要 (1) 前言 (2) 第一章时间序列的预测函数及其评价指标 (4) 第一节预测函数 (5) 第二节评价预测的数量指标 (5) 第二章 BP神经网络 (6) 第一节 BP神经网络的结构 (6) 第二节 BP神经网络算法及公式推导 (7) 第三节 BP神经网络算法的步骤 (9) 第三章基于BP神经网络的时间序列预测及其应用 (11) 第四章结论 (14) 总结与体会 (15) 致谢词 (15) 参考文献 (15) 附录 (16)

摘要 首先,本文介绍了时间序列的含义和时间序列预测在国内外的研究情况,列举了两个时间序列预测的实际例子。文中阐述了时间序列预测及其评价指标,比较了各评价指标之间的长处和短处。其次, 本文阐述了BP神经网络算法及其公式推导。给出了BP神经网络算法的流程图。最后,本文从实用出发,列出了1993年至2006年我国GDP的数据,此组数据呈现出增长趋势,这种增长趋势反映了近十几年我国经济的快速增长。用BP神经网络预测出我国2007年的GDP是200790亿元, 这表明今后我国经济有减缓的迹象,这也说明我国近几年宏观经济调控获得了一定的成果。 【关键词】时间序列神经网络预测 GDP Abstract This grade paper, times series, and the development of times series forecast are introduced at first, and then the practical examples of times series forecast are enumerated. The function of times series forecast and its evaluative index are given. We compare the advantage and disadvantage of these evaluative indexes. Secondly, The principles of BP neural network and BP neural network’s algorithm are presented. Finally, we particularize our country GDP statistics, which it increases, which it indicates economy’s fast increasing, year by year, from 1993 to 2006. We also study BP neural network’s forecast algorithm. Our country GDP in 2007,wiche it is about 200790 hundred millions is forecasted by BP neural network, and it shows that the Chinese macro-economy policy in ten years are succeed. Keywords time series neural network prediction GDP

MATLAB动态神经网络在时间序列预测中的应用

MATLAB动态神经网络在时间序列预测中的应用 摘要:本文在介绍了Matlab神经网络工具箱的基础上,主要对时间序列预测工具箱的使用作了说明,并用实例仿真说明如何进行时间序列预测的调用实现,通过不断的调整参数,最后使训练的模型比较理想,满足实际的需求,表明了直接使用时间序列预测的有效性,并为Matlab神经网络工具箱的使用提供了新的方法。 关键词:Matlab;神经网络;时间序列;预测 引言 时间序列是根据时间顺序得到跟时间相关的变量或者参数的观测数据[1]。对时间序列的研究主要是挖掘其中有价值的信息,找到其中变化的内在规律[2]。时间序列预测是时间序列分析研究的主要内容,是指根据现有的和历史的时间序列的数据,建立能反映时间序列中所包含的动态依存关系的数学模型[3],从而能对序列未来的趋势做出合理的预测。简单的说,时间序列预测就是用已有的数据预测下一个时间段的值。目前,时间序列预测已经广泛应用在自然界、经济、化学、科学工程等各个领域。 随着Matlab版本的不断更新,神经网络工具箱不断的完善,使得仿真的实现日益简单,R2010b后的版本对时间序列预测的实现不需要手动写代码,网络训练完毕,从Simple Script可看到网络代码,并可对代码进行编辑、改编,因此,只要调用就可应用在各个领域。本文结合时间序列预测的特点,将Matlab神经网络工具箱中的时间序列预测应用到温度预测的实例中,通过快速的仿真及不断的调整参数,从而形成较理想的数学模型,为后期进行温度的预测奠定了基础。 1Matlab神经网络工具箱简介 神经网络分为静态和动态两类。静态神经网络是无反馈、无记忆的,输出仅依赖于当前的输入,例如BP神经网络和RBF神经网络。动态神经网络是有记忆的神经网络,其输出依赖于当前和以前的输入。动态神经网络又分为有反馈和无反馈,有反馈指输出依赖于当前输入和前一个输入输出,无反馈指输出依赖于当前和之前的输入。因此,动态神经网络比静态神经网络功能强,本文选择动态神经网络进行时间序列预测。 Matlab神经网络工具箱提供了一系列用于模型训练的工具,包括曲线拟合工具箱、模式识别工具箱、聚类工具箱和时间序列工具箱,利用这些工具箱可进行快速的调整参数,通过仿真得到直观的结果。另外,Matlab神经网络工具箱还提供人机交互界面,可根据提示一步一步的完成模型的训练,并对仿真的结果进行分析,直到满足要求为止。 选择时间序列工具箱或者直接在命令窗口中输入ntstool,可打开时间序列预测工具箱界面,根据数据选择符合哪种情况,根据人机交互界面的提示,将数据

小波神经网络及其应用

小波神经网络及其应用 1014202032 陆宇颖 摘要:小波神经网络是将小波理论和神经网络理论结合起来的一种神经网络,它避免了BP 神经网络结构设计的盲目性和局部最优等非线性优化问题,大大简化了训练,具有较强的函数学习能力和推广能力及广阔的应用前景。首先阐明了小波变换和多分辨分析理论,然后介绍小波神经网络数学模型和应用概况。 1.研究背景与意义 人工神经网络是基于生物神经系统研究而建立的模型,它具有大规模并行处理和分布式存储各类图像信息的功能,有很强的容错性、联想和记忆能力,因而被广泛地应用于故障诊断、模式识别、联想记忆、复杂优化、图像处理以及计算机领域。但是,人工神经网络模型建立的物理解释,网络激活函数采用的全局性函数,网络收敛性的保证,网络节点数的经验性确定等问题尚有待进一步探讨和改善。 小波理论自 Morlet 提出以来,由于小波函数具有良好的局部化性质,已经广泛渗透到各个领域。小波变换方法是一种窗口大小固定但其形状可以改变, 时间窗和频率窗都可以改变的时频局部化分析方法, 由于在低频部分具有较高的频率分辨率和较低的时间分辨率, 在高频部分具有较高的时间分辨率和较低的频率分辨率, 所以被誉为数学显微镜。正是这种特性, 使小波变换具有对信号的自适应性。基于多分辨分析的小波变换由于具有时频局部化特性而成为了信号处理的有效工具。实际应用时常采用Mallat快速算法,利用正交小波基将信号分解到不同尺度上。实现过程如同重复使用一组高通和低通滤波器把信号分解到不同的频带上,高通滤波器产生信号的高频细节分量,低通滤波器产生信号的低频近似分量。每分解一次信号的采样频率降低一倍,近似分量还可以通过高通滤波和低通滤波进一步地分解,得到下一层次上的两个分解分量。 而小波神经网络(Wavelet Neural Network, WNN)正是在近年来小波分析研究获得突破的基础上提出的一种人工神经网络。它是基于小波分析理论以及小波变换所构造的一种分层的、多分辨率的新型人工神经网络模型,即用非线性小波基取代了通常的非线性Sigmoid 函数,其信号表述是通过将所选取的小波基进行线性叠加来表现的。 小波神经网络这方面的早期工作大约开始于1992 年,主要研究者是Zhang Q、Harold H S 和焦李成等。其中,焦李成在其代表作《神经网络的应用与实现》中从理论上对小波神经网络进行了较为详细的论述。近年来,人们在小波神经网络的理论和应用方面都开展了不少研究工作。 小波神经网络具有以下特点。首先,小波基元及整个网络结构的确定有可靠的理论根据,可避免BP 神经网络等结构设计上的盲目性;其次,网络权系数线性分布和学习目标函数的凸性,使网络训练过程从根本上避免了局部最优等非线性优化问题;第三,有较强的函数学习能力和推广能力。 2.数学模型与小波工具 2.1 小波变换及多分辨分析 L R(或更广泛的Hilbert 空间)中,选择一个母小波函数(又称为基本在函数空间2() ,使其满足允许条件: 小波函数)()x

基于神经网络的Mackey-Glass时间序列预测

目录 1引言 (1) 2MG时间序列 (1) 2.1MG时间序列简介 (1) 2.2利用dde23函数求解MG时间序列 (1) 3BP神经网络 (3) 3.1神经网络总体思路 (3) 3.2MATLAB中的newff函数 (3) 3.3BP神经网络的训练 (4) 3.4构建输入输出矩阵 (6) 3.5对MG时间序列未来值预测 (6) 4参考文献 (7) 5附录 (8)

1 引言 本文选用的神经网络的是BP 神经网络,利用MATLAB 编程实现。首先通过求解Mackey-Glass 方程得到具有513个数据的Mackey-Glass 时间序列,其中一半用于训练神经网络,一半用于检测预测值。BP 神经网络输入层神经元个数为4,隐含层为8,输出层为1。利用BP 神经网络工具箱构建神经网络并对其进行训练,然后利用训练好的神经网络对未来值进行预测,画出比较图。 2 MG 时间序列 2.1 MG 时间序列简介 Mackey-Glass 混沌系统一类非常典型的混沌系统,混沌系统模型由以下的时滞微分方程来描述: )() (1) ()(t x t x t x dt t dx βτταγ--+-= 其中 α =0.2,β =0.1,γ =10,τ是可调参数,x(t)是在t 时刻的时间序列的值。MG 方程表现出了某种周期性与混沌特性,在τ<16.8时,表现出周期性,在 τ>16.8时,则表现出混沌特性。 2.2 利用dde23函数求解MG 时间序列 本课程设计中取τ=10,也就是说MG 时间序列会表现为周期性。可以利用MATLAB 求解MG 方程,MG 方程是一个时滞微分方程,其中一种求解方法是利用MATLAB 的dde23函数。具体求解方法是:首先建立MG .m 函数文件,代码如下 function y = MG(t,x,z) %UNTITLED Summary of this function goes here % Detailed explanation goes here

浅谈基于小波分析的神经网络

浅谈基于小波分析的神经网络 摘要:基于小波分析的神经网络在我们的日常生产中有着重要的作用,尤其是在故障检测中,正因为有了它的存在,使得我们能更好的对一些机器内部微小的部件进行检测。在一定程度上,避免了人工检测工作量大且准确度不高的情况,降低了检验的成本,减少了因零件损坏而带来的损失,为工业的生产提供了极大的帮助。 关键词:小波分析,神经网络,故障诊断 随着科学的进步与时代的发展,神经网络正慢慢的运用到我们的日常生活与生产之中。从1943年人们首次提出了人工神经网络这一概念至今,神经网络已经与越来越多的其他技术结合了起来,例如,结合神经元的混沌属性提出混沌神经网络,应用于组合优化的问题中,与粗集理论结合,应用于对数据的分类处理,与分形理论结合,应用于图形识别、图像编码、图像压缩等,与小波分析结合,应用于机械设备的故障检测中。以下是我对基于小波分析的神经网络的见解。 一、概述 小波分析即小波变换,是1981年Morlet首先提出的,经过发展后成为了一门学科,小波分析对低频信号在频域和高频信号在时域里有着较好的分辨率。而神经网络特有的对非线性适应性信息处理能力,当它与小波分析相结合后,使得它们能在对高压电网的信号处理,机械故障的检测等方面发挥了重要的作用。

二、小波神经网络的算法 小波神经网络的算法大体的思路是这样的,小波神经网络的核心是隐层神经元的激活函数小波基函数(Morlet )进行非线性映射,信号通路只进行前向传递,待分类信号进行前向传递的同时,误差信号进行反向的传递。输出层的传递函数为S 函数,小波函数的拓扑结构如下所示: 小波函数的修正公式如下: (k 1)(k)*E mc ωωη ωω?+=++? (1) a(k 1)(k)*E a mc a a η?+=++? (2) b(k 1)(k)*E b mc b b η ?+=++? (3) 误差函数如下: 211 1(y yt )2N M n n m m n m E N ===-∑∑ (4) 输入层 隐含层 输出层

神经网络预测时间序列

神经网络预测时间序列 如何作预测?理想方法是利用已知数据建立一系列准则,用于一般条件下预测,实际上由于系统的复杂性而不太可能,如股票市场预测。另一种途径是假设一次观测中过去、未来值之间存在联系。其中一种选择是发现一个函数,当过去观测值作为输入时,给出未来值作为输出。这个模型是由神经网络来实现的。 1.2 神经网络预测时间序列 (1) 简单描述 在时间序列预测中,前馈网络是最常使用的网络。在这种情形下,从数学角度看,网络成为输入输出的非线性函数。记一个时间序列为}{n x ,进行其预测可用下式描述: ),,(1+-1-+=m n n n k n x x x f x (1) 时间序列预测方法即是用神经网络来拟合函数)(?f ,然后预测未来值。 (2) 网络参数和网络大小 用于预测的神经网络性质与网络参数和大小均有关。网络结构包括神经元数目、隐含层数目与连接方式等,对一个给定结构来说, 训练过程就是调整参数以获得近似基本联系,误差定义为均方根误差,训练过程可视为一个优化问题。 在大多数的神经网络研究中,决定多少输入与隐层单元数的定量规则问题目前尚未有好的进展,近有的是一些通用指导:首先, 为使网络成为一个完全通用的映射,必须至少有一个隐层。1989年证明一个隐层的网可逼近闭区间内任意一个连续函数。其次,网络结构要尽可能紧致,即满足要求的最小网络最好。实际上,通常从小网络开始。逐步增加隐层数目。同样输入元数目也是类似处理。 (3) 数据和预测精度 通常把可用的时间序列数据分为两部分:训练数据和检验数据。训练数据一般多于检验数据两倍。检验过程有三种方式: 短期预测精度的检验。用检验数据作为输入,输出与下一个时间序列点作比较,误差统计估计了其精度。 长期预测中迭代一步预测。以一个矢量作为输入,输出作为下一个输入矢量的一部分,递归向前传播。 直接多步预测。即用1+-1-m n n n x x x ,,直接进行预测,输出k n x +的预测值,其中 1>k 。

小波神经网络及其应用

小波神经网络及其应用 陆宇颖 摘要:小波神经网络是将小波理论和神经网络理论结合起来的一种神经网络,它避免了BP 神经网络结构设计的盲目性和局部最优等非线性优化问题,大大简化了训练,具有较强的函数学习能力和推广能力及广阔的应用前景。首先阐明了小波变换和多分辨分析理论,然后介绍小波神经网络数学模型和应用概况。 1. 研究背景与意义 人工神经网络是基于生物神经系统研究而建立的模型,它具有大规模并行处理和分布式存储各类图像信息的功能,有很强的容错性、联想和记忆能力,因而被广泛地应用于故障诊断、模式识别、联想记忆、复杂优化、图像处理以及计算机领域。但是,人工神经网络模型建立的物理解释,网络激活函数采用的全局性函数,网络收敛 即 ,焦李神经网络2. 2.1()x ,使式中为的Fourier 变换。对作伸缩、平移变换得到小波基函数系 对任意2()()f x L R ∈,其连续小波变换定义为: 反演公式为: 在实际应用中,特别是计算机实现中,往往要把上述的连续小波及其变换离散化,通常采用二进制离散,即 令2,2m m a b k ==,则 二进小波一定是一个允许小波,且是一个正交小波基。考虑一个连续的、平方可积的函数 2()()f x L R ∈在分辨率2m 下的逼近()m f x ,由多分辨分析理论可知:

()x Φ是尺度函数,对其作伸缩、平移变换得到()mk x Φ。 Mallat 同时证明了函数()f x 在2m 和12m -分辨率下的信息差别(即细节)()m D f x ,可以通过将函数() f x 在一小波正交基上分解而获得,从而定义了一种完全而且正交的多分辨率描述,即小波描述。 ()mk x ψ就是式(5)定义的二进小波,则()f x 在12m -分辨率下的逼近式为: Mallat 并指出,对于任意一个函数 2()()f x L R ∈可以在一组正交小波基上展开: 式(11)是一个平方可积函数的小波分解,提供了小波神经网络设计的理论框架。 .. 12(,)x x ο 则有2.2 (ψ(f x 式(Lk a 与式 (17i c i 则有: 即(21)=f Ac 式(20)的最小二乘解为: +A 被称为A 的伪逆矩阵。且 如果样本i x 均匀分布,(1,2,...,)θ=i i n 是正交基, 则T A A 是一个?n n 单位矩阵,且

神经网络对时间序列的处理(1)

神经网络对时间序列的处理 Georg Dorffner 奥地利维也纳大学人工智能研究所医疗控制论和人工智能部门 摘要: 本文介绍了神经网络在时间序列处理的最常见类型,即模式识别和时空模式的预测。重视神经网络模型和更多经典时间序列的处理方法之间的关系,尤其是预测。文章首先通过介绍基本的时间序列加工、讨论了前馈以及递归神经网络,和他们非线性模型在时空模式的依赖能力方面。 1.介绍 世界是一直在变的。无论我们观察还是措施——个物理价值,诸如温度和自由交易的价格好—在不同的时间点。经典模式识别,并且与它的很大一部分神经网络应用中,主要涉及了检测系统模式以一个数组的形式返回(静态模式)。典型的应用包括输入向量的分类成多个类别之一(判别分析),或近似描述之间的可见的依赖关系(倒退)。当随时间变化而变化也被考虑进去,额外的,时间维就是补充。虽然在很大程度上这一问题仍然可以被经典模式识别,一些附加的重要方面仍然起作用。统计领域的时空数据分析这种关注(例如具有一定的时空维度的数据),通常是被称为时间序列处理。 本文旨在介绍利用神经网络的基本原理为时间序列处理。作为一个教程,它自然只能触及表面的这个行业,留下许多重要的细节都没动。不过,概述最相关方面的工作基础,形成了这个领域的佼佼者。这篇文章是很有参考价值的一个指南,并给出了更远、更详细的文学。关于神经网络学习算法的基本知识建筑已被假定。 2.时间序列处理 2.1.基本要素 在正式的条件,时间序列是一系列向量,根据t:~x(t):t =0;1;…… (1)。 向量的组成部分可以是任何可观察变量,诸如: 1)在一幢建筑里的空气温度 2)在给定的证券交易所的某些产品价格 3)在一个特定城市新出生的人数 4)在一个特定社区的水的总消费金额 从理论上讲,x ~可以被看作是时间变量t的连续函数。然而用于实际目的时,时间是通常被看作离散的时间间隔,这就导致在每个时间间隔的终点产生x的实体。这就是为什么一个人说话的时间顺序或系列。时间间隔的尺寸通常依手边问题,可以是任何东西,从几秒,几小时到几天,甚至几年。 在许多情况下,可观察量只有在离散的时间间隔(例如,在每一个小时,或天某一商品的价格)必然会形成时间序列。在其他情况下(例一个城市的新出生的人数),价值观必须累积或均一段时间间隔(如每月引起的出生人数)得到系列。在时间确实是连续的领域(例如当温度在某一地点是可见) 一个人必须点测量变量的藉所选择的时间间隔来获得一个系列(如每个小时的温度)。这就是所谓的抽样。取样频率就是所测量时段的点个数,在这种情况下是一个非常重要的参数,因为不同频率能从本质上改变所获得时间序列的主要特点。 值得注意的是,有另一个领域非常密切相关,即加工时间序列信号处理。例如语音识别,即异常模式心电图的发现(ECGs),或脑电图的自动分级(EEGs)。一个信号,当采样成一串值的离散的时间间隔时,构成上述定义的时间序列。因此和时间序列信号处理没有一个正式的区别。在普遍的应用程序中可以发现不同(例如单个信号的识别和滤波;时间序列处理的预测),自然的时间序列(一个采样间隔时间信号通常是一小段时间,而在时间序列处理区间常是小时)。但这只是一个从原型中的应用的观察,并没有明确的边界。因此,时间序列处理可借鉴对信号处理的方法探索,反之亦然。神经网络应用程序在信号处理的概述在文献【54,51】。 如果矢量~ x只含有一个组件,在许多应用场合情况中,有的说是一个单变量的时间序列,否则它就是一个多元。它非常仰赖棘手问题的单变量治疗是否会导致图案识别的结果。如果几个可观察量相互影响(例如空气温度和消耗的水量)一个多变量分析治疗(即基于几个可观察量的分析{~x超过一个变量})将被标明。在大多数讨论中,我们依然遵循单变量的事件序列处理。 2.2处理类型 根据时间序列分析的目的,时间序列分析的典型应用可以分为: 1.时间序列未来发展的预测 2.时间序列的分类或分成几类的一部分 3.根据参数模型对时间序列的描述

小波神经网络预测的代码1

clc; clear all; %设定期望的误差最小值 err_goal=0.01; %设定最大循环次数 max_epoch=50; %设定修正权值的学习速率0.01-0.7 lr=0.7; epoch=0; x=0:0.01:0.3;%输入时间序列 %d=sin(8*pi*x)+sin(4*pi*x)+5*sin(pi*x);% d=[1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 10 9 8 7];%目标输出序列M=size(x,2);%输入节点的个数 N=M;%输出节点的个数 n=10;%隐形节点的个数 %这个地方需要改进,由于实际上隐形节点的个数可以通过小波的时频分析确定 Wjk=randn(n,M); Wij=randn(N,n); % a=randn(1,n); a=1:1:n; b=randn(1,n); % stepa=0.2*(x(M)-x(1)); % a=stepa:1n-1)+stepa; % step=(x(M)-x(1))/n; % b=x(1)+step:step:x(1)+n*step; % y=zeros(1,N);%输出节点初始化 y=zeros(1,N);%输出节点初始化 net=zeros(1,n);%隐形节点初始化 net_ab=zeros(1,n);%隐形节点初始化 %step2--------对网络进行训练------------------------------------------- for i=1:1:N for j=1:1:n for k=1:1:M net(j)=net(j)+Wjk(j,k)*x(k); net_ab(j)=(net(j)-b(j))/a(j); end y(i)=y(i)+Wij(i,j)*mymorlet(net_ab(j)); %mymorlet是judyever编写的小波函数,以后可以扩展成输入不同的小波名字即可 % y(i)=mysigmoid(2,y(i)); end end

小波神经网络研究进展及展望_陈哲

综 述 小波神经网络研究进展及展望 陈 哲 冯天瑾 (青岛海洋大学电子工程系,青岛,266003)摘 要 关于小波分析与人工神经网络结合的研究,近些年来已成为信号处理学科的热点之一,已有大量的研究成果见诸各种学术刊物和会议论文。小波变换具有良好的时频局部性质,神经网络则具有自学习功能和良好 的容错能力,小波神经网络(W NN )由于较好地结合了两者的优点而具有强大的优势。作者较系统地综述了小 波神经网络的研究进展,讨论了小波神经网络的主要模型和算法,并就其存在的一些问题,应用与发展趋势进 行了探讨。 关键词 神经网络;小波分析;小波神经网络 中图法分类号 T P 911.7 小波自80年代提出以来,理论和应用都得到了巨大的发展,小波分析的出现被认为是傅立叶分析的突破性进展[1~3]。多层感知器(M ultila yer Perceptr on,M L P)是一种广泛应用的神经网络模型,实践证明M L P 具有较好的空间映射能力和推广能力。目前,神经网络的理论研究日趋深入,其重要发展方向之一,就是注重与小波、混沌、模糊集等非线性科学理论相结合。小波变换具有时频局部特性和变焦特性,而神经网络具有自学习、自适应、鲁棒性、容错性和推广能力,如何把两者的优势结合起来,一直是人们关注的问题。一种方法是用小波分析对信号进行预处理,即以小波空间作为模式识别的特征空间。通过将小波基与信号的内积进行加权和来实现信号的特征提取,然后将提取的特征向量送入神经网络处理;另一种即所谓的小波神经网络(W av elet neura l netw or k,W NN )或小波网络,把小波变换与神经网络有机地结合起来,充分继承了两者的优点。小波与前馈神经网络的结合是小波网络的主要研究方向,也是本文着重讨论的内容。小波还可以与其它类型的神经网络相结合:例如用Koho nen 网络对信号做自适应小波分解[4],RBF 网络与小波的结合[5]等。1 小波神经网络 小波神经网络可看作是以小波函数为基底的一种函数连接型网络,也可以认为是径向基函数(Radial ba-sis functio n,RBF)网络的推广,但它又具有与一般前馈网络和RBF 网络所不同的特点,在神经网络研究领域中具有巨大的潜力。现就其主要模型和算法综述如下。 1.1小波网络基本模型 Pati 和Krish napra sad [6]最早研究了神经网络与小波变换的联系,提出了离散仿射小波网络模型。其思想是将离散小波变换引入神经网络模型,通过对Sig moid 函数的平移伸缩构成L 2(R )中的仿射框架,进而构造小波神经网络。1992年Zhang Qing hua 和Benv eniste [7]明确提出了小波网络的概念和算法。其思想是用小波元代替了神经元,即用已定位的小波函数代替S ig modi 函数作激活函数,通过仿射变换建立起小波变换与网络系数之间的联接,并应用于函数逼近。随后Szu 等[8]又提出了基于连续小波变换的两种自适应小波神经网络模型。一种用于信号表示,偏重于函数逼近;另一种偏重于选取合适的小波做特征提取,其实质是在小波特征空间中寻找一组最佳的小波基,因不涉及重构问题,小波的正交性要求不是很苛刻, 第29卷 第4期 1999年10月 青岛海洋大学学报J OU RN AL OF OCE AN UVIVE RSI TY OF Q INGDAO 29(4):663~668  Oct.,1999  国家自然科学基金课题(69675005)资助 收稿日期:1998-09-23;修订日期:1999-05-11 陈 哲,男,1976年6月出生,硕士生。

用小波神经网络来对时间序列进行预测

/* Note:Your choice is C IDE */ #include"stdio.h" void main() { }/*用小波神经网络来对时间序列进行预测 */ /*%File name : nprogram.m %Description : This file reads the data from %its source into their respective matrices prior to % performing wavelet decomposition. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Clear command screen and variables */ clc; clear; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % user desired resolution level (Tested: resolution = 2 is best)*/ level = menu('Enter desired resolution level: ', '1',... '2 (Select this for testing)', '3', '4'); switch level case 1, resolution = 1; case 2, resolution = 2; case 3, resolution = 3; case 4, resolution = 4; end msg = ['Resolution level to be used is ', num2str(resolution)]; disp(msg); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % user desired amount of data to use */ data = menu('Choose amount of data to use: ', '1 day', '2 days', '3 days', '4 days',... '5 days', '6 days', '1 week (Select this for testing)'); switch data case 1, dataPoints = 48; /*%1 day = 48 points */ case 2, dataPoints = 96; /* %2 days = 96 points */ case 3, dataPoints = 144; /*%3 days = 144 points */ case 4, dataPoints = 192; /*%4 days = 192 points */ case 5, dataPoints = 240; /* %5 days = 240 points */

MATLAB动态神经网络在时间序列预测中的应用

龙源期刊网 https://www.360docs.net/doc/b03174577.html, MATLAB动态神经网络在时间序列预测中的应用 作者:张云丽韩宪忠王克俭 来源:《科学与技术》2014年第08期 摘要:本文在介绍了Matlab神经网络工具箱的基础上,主要对时间序列预测工具箱的使 用作了说明,并用实例仿真说明如何进行时间序列预测的调用实现,通过不断的调整参数,最后使训练的模型比较理想,满足实际的需求,表明了直接使用时间序列预测的有效性,并为Matlab神经网络工具箱的使用提供了新的方法。 关键词:Matlab;神经网络;时间序列;预测 中图分类号:TP391.41 文献识别码:A 引言 时间序列是根据时间顺序得到跟时间相关的变量或者参数的观测数据[1]。对时间序列的 研究主要是挖掘其中有价值的信息,找到其中变化的内在规律[2]。时间序列预测是时间序列 分析研究的主要内容,是指根据现有的和历史的时间序列的数据,建立能反映时间序列中所包含的动态依存关系的数学模型[3],从而能对序列未来的趋势做出合理的预测。简单的说,时 间序列预测就是用已有的数据预测下一个时间段的值。目前,时间序列预测已经广泛应用在自然界、经济、化学、科学工程等各个领域。 随着Matlab版本的不断更新,神经网络工具箱不断的完善,使得仿真的实现日益简单, R2010b后的版本对时间序列预测的实现不需要手动写代码,网络训练完毕,从Simple Script 可看到网络代码,并可对代码进行编辑、改编,因此,只要调用就可应用在各个领域。本文结合时间序列预测的特点,将Matlab神经网络工具箱中的时间序列预测应用到温度预测的实例中,通过快速的仿真及不断的调整参数,从而形成较理想的数学模型,为后期进行温度的预测奠定了基础。 1Matlab神经网络工具箱简介 神经网络分为静态和动态两类。静态神经网络是无反馈、无记忆的,输出仅依赖于当前的输入,例如BP神经网络和RBF神经网络。动态神经网络是有记忆的神经网络,其输出依赖于当前和以前的输入。动态神经网络又分为有反馈和无反馈,有反馈指输出依赖于当前输入和前一个输入输出,无反馈指输出依赖于当前和之前的输入。因此,动态神经网络比静态神经网络功能强,本文选择动态神经网络进行时间序列预测。

基于神经网络的MackeyGlass时间序列预测

目录 1引言2 2MG时间序列2 2.1MG时间序列简介2 2.2利用dde23函数求解MG时间序列2 3BP神经网络4 3.1神经网络总体思路4 3.2MATLAB中的newff函数4 3.3BP神经网络的训练5 3.4构建输入输出矩阵6 3.5对MG时间序列未来值预测7 4参考文献8 5附录8

1 引言 本文选用的神经网络的是BP 神经网络,利用MATLAB 编程实现。首先通过求解Mackey-Glass 方程得到具有513个数据的Mackey-Glass 时间序列,其中一半用于训练神经网络,一半用于检测预测值。BP 神经网络输入层神经元个数为4,隐含层为8,输出层为1。利用BP 神经网络工具箱构建神经网络并对其进行训练,然后利用训练好的神经网络对未来值进行预测,画出比较图。 2 MG 时间序列 2.1 MG 时间序列简介 Mackey-Glass 混沌系统一类非常典型的混沌系统,混沌系统模型由以下的时滞微分方程来描述: )() (1) ()(t x t x t x dt t dx βτταγ--+-= 其中 α =0.2,β =0.1,γ =10,τ是可调参数,x(t)是在t 时刻的时间序列的值。MG 方程表现出了某种周期性与混沌特性,在τ<16.8时,表现出周期性,在 τ>16.8时,则表现出混沌特性。 2.2 利用dde23函数求解MG 时间序列 本课程设计中取τ=10,也就是说MG 时间序列会表现为周期性。可以利用MATLAB 求解MG 方程,MG 方程是一个时滞微分方程,其中一种求解方法是利用MATLAB 的dde23函数。具体求解方法是:首先建立MG .m 函数文件,代码如下 function y = MG(t,x,z) %UNTITLED Summary of this function goes here % Detailed explanation goes here xlag=z(1,:);

相关文档
最新文档