Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
clear
load('data20100513_online');
load('state1')
load('data20100210_online');
load('state2')
%% Step 1. Structure determination and initial parametr setting
n=3; %dimenze fuzzy systemu
M=10; %pocet pravidel 10 je ok
alpha=1; %learning rate (2 je nej s M=14 okno=100, q=1)
macBeta=1;
macGamma=0.1;
macN=-1;
X=do;
X1=Fm;
leBeta=2.59%2.52;
oknoM=20; %200 ok
%% Online initial parameter choosing method
pre_x=zeros(n,M);
pre_y=linspace(0,0,M+1);
for i=1:M
% u=i;
pre_x(2,i)=X(6+i*10);
pre_x(1,i)=X(i*10);
pre_x(3,i)=X(19+i*10); %X(19+i*10);
% pre_x(i)=X(i);
% pre_y(i)=X(i);
% pre_y(i+1)=pre_y(i)+sin(u);
end
%% Step 1. Structure determination and initial parametr setting
y=pre_y(2:M+1);
x=pre_x;
x;
sigma=rand([n,M])/.010;
pre_sigma=sigma;
for i=1:n
sigma(i,:)=(max(x(i,:))-min(x(i,:)))/(2*M);
end
x_data=linspace(0.5,1,n);
y_data=0.1;
ZZ=linspace(1,1,M);
z=zeros(n,M);
b=0;
a=0;
f=0;
vzorky=1600;
epoch=zeros(1,vzorky);
fuzzy_y=zeros(1,vzorky);
system_y=zeros(1,vzorky);
x_data=[0,0];
x;
f=0;
prirustek_y=zeros(vzorky,M);
prirustek=zeros(vzorky,M,2);
prirustek_sigma=zeros(vzorky,M,2);
err=zeros(vzorky,1);
for p=30:vzorky
y_data=X(p);
x_data(1)=X(p-1);
x_data(2)=X(p-6);
x_data(3)=X(p-19);
% if p==1500
% y_data=X(p)+0.01*X(p);
% X(p)=X(p)+0.01*X(p);
% x_data(1)=X(p-1);
% x_data(2)=X(p-18);
% end
% if (p<vzorky/2)
% x_data=y_data;%macBeta*(x_data)/(1+x_data^macN)-macGamma*x_data(k);
% % x_data(1)=sin(p/10);
% % x_data(2)=y_data;
% y_data=macBeta*(x_data)/(1+x_data^macN)-macGamma*x_data;
% x_data;
% else
% % x_data(1)=sin(p/10)*cos(x_data(1));
% % x_data(2)=y_data;
% % y_data=x_data(1)+x_data(2);
% % x_data;
% % x_data(1)=sin(p/10);
% % x_data(2)=y_data*0.5;
% % y_data=x_data(1)+x_data(2);
% % x_data;
% x_data=y_data;%macBeta*(x_data)/(1+x_data^macN)-macGamma*x_data(k);
% % x_data(1)=sin(p/10);
% % x_data(2)=y_data;
% y_data=macBeta*(x_data)/(1+x_data^macN)-macGamma*x_data(k);
% x_data;
% end
y_data=X(p);
x_data(1)=X(p-1);
x_data(2)=X(p-6);
x_data(3)=X(p-19);
%fuzzy_y(p)=f;
for q=1:10
%% Step 2. Present input and calculate the output of the fuzzy system
b=0;
a=0;
f=0;
ZZ=linspace(1,1,M);
z=zeros(n,M);
for l=1:M
for i=1:n
z(i,l)=membershipFunction(x_data(i),x(i,l),sigma(i,l));
ZZ(l)=ZZ(l)*z(i,l);
end
end
b=sum(ZZ);
for l=1:M
a=y(l)*ZZ(l)+a;
end
f=a/b;
if q==1,f-y_data;,end
err(q)=f-y_data;
if (p==13)
p;
end
if min(abs(err(q)))<0.0001,err(q)=err(q);break,end
y_old=y;
x_old=x;
sigma_old=sigma;
%% Step 3. Update the parameters.
for j=1:M % PICOVINY V INDEXOVANI
y(j)=y_old(j)-alpha*(f-y_data)*ZZ(j)/b;
prirustek_y(p,j)=abs(-alpha*(f-y_data)*ZZ(j)/b)+prirustek_y(p,j);
d_y(j,q)=-alpha*(f-y_data)*ZZ(j)/b;
for k=1:n
prirustek(p,j,k)=abs((alpha*(f-y_data)/b)*(y_old(j)-f)*ZZ(j)*2*(x_data(k)-x_old(k,j))/sigma_old(k,j)^2)+prirustek(p,j);
x(k,j)=x(k,j)-(alpha*(f-y_data)/b)*(y_old(j)-f)*ZZ(j)*2*(x_data(k)-x_old(k,j))/sigma_old(k,j)^2;
sigma(k,j)=abs(sigma_old(k,j)-(alpha*(f-y_data)/b)*(y_old(j)-f)*ZZ(j)*2*((x_data(k)-x_old(k,j))^2)/sigma_old(k,j)^3);
prirustek_sigma(p,j,k)=abs((alpha*(f-y_data)/b)*(y_old(j)-f)*ZZ(j)*2*((x_data(k)-x_old(k,j))^2)/sigma_old(k,j)^3)+prirustek_sigma(p,j);
end
end
end
epoch(p)=q;
system_y(p)=y_data;
fuzzy_y(p)=f;
end
max(prirustek)
%plot(err)
plot(system_y,'g')
hold on
plot(fuzzy_y,'r')
figure(2)
plot(epoch)
figure(3)
plot(sum(prirustek(:,:),2))
figure(4)
plot(sum(prirustek_sigma(:,:),2))
figure(5)
plot(sum(prirustek_y,2))
% for i=1:M
% figure(6)
% znormovano(i,:)=transpose(zscore(prirustek_y((1500+plovouci-okno+1):1500+plovouci,i)));
% plot(zscore(prirustek_y((1500+plovouci-okno+1):1500+plovouci,i)))
% hold on
% figure(7)
% plot(zscore(prirustek_sigma((1500+plovouci-okno+1):1500+plovouci,i)))
% end
% znormovano(znormovano<0)=0;
% bar(sum(znormovano))
%% LE
z_score_y=zeros(1800,M);
z_score_s=zeros(1800,M,n);
z_score_x=zeros(1800,M,n);
LE=zeros(1600,1);
for i=201:1600
for j=1:M
z_score_y(i,j)=(abs(prirustek_y(i,j))-mean(abs(prirustek_y(i-oknoM:i))))/std(abs(prirustek_y(i-oknoM:i)));
for k=1:n
z_score_s(i,j,k)=(abs(prirustek_sigma(i,j,k))-mean(abs(prirustek_sigma(i-oknoM:i,j,k))))/std(abs(prirustek_sigma(i-oknoM:i,j,k)));
z_score_x(i,j,k)=(abs(prirustek(i,j,k))-mean(abs(prirustek(i-oknoM:i,j,k))))/std(abs(prirustek(i-oknoM:i,j,k)));
end
end
z_score_y(z_score_y<0)=0;
z_score_s(z_score_s<0)=0;
z_score_x(z_score_x<0)=0;
z_score_s(isnan(z_score_s))=0;
z_score_x(isnan(z_score_x))=0;
z_score_x(isinf(z_score_x))=0;
z_score_s(isinf(z_score_s))=1000;
z_score_y(z_score_y<leBeta )=0;
LE_y(i)=sum(z_score_y(i,:));
LE_s1(i)=sum(z_score_s(i,:,1));
LE_s2(i)=sum(z_score_s(i,:,2));
LE_x1(i)=sum(z_score_x(i,:,1));
LE_x2(i)=sum(z_score_x(i,:,2));
end
figure(8)
plot(LE_y(250:1600))
% figure(9)
% plot(LE_s1(1000:2000))
% figure(10)
% plot(LE_s1(1000:2000)+LE_y(1000:2000))
% figure(11)
% plot(LE_x1(1000:2000))
toPlotLE=LE_y(1:1600);
toPlotLE(toPlotLE>100)=100;
toPlot_fuzzy=fuzzy_y((1:1600));
toPlot_sys=system_y(1:1600);
figure(9)
plot(toPlotLE(1:900),'LineWidth',2)
%title('Learning Entropy Order 1, beta=0, M=200','fontsize',14);
xlabel('k','fontsize',12)
ylabel('E^1 [-]','fontsize',12)
hold on
plot(1*state_20100210(1:900,2),'r','LineWidth',2)
% plot(1*state_20100513(1:900,2),'r','LineWidth',2)
figure(10)
plot(toPlot_fuzzy(30:930),'r','LineWidth',2)
%title 'time series vs adaptive predictor output'
xlabel('k','fontsize',12)
ylabel('y [%]','fontsize',12)
hold on
plot(toPlot_sys(30:930),'b','LineWidth',2)
hold off
figure(11)
plot(toPlot_fuzzy(30:930)-toPlot_sys(30:930),'LineWidth',2)
xlabel('k','fontsize',12)
ylabel('y [%]','fontsize',12)
title 'e [%]'
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team