clear all
close all
clc

%%%%% NN KERNEL SMOOTHER CON DATOS PRECARGADOS CIRCULARES
clear all
close all
clc
load('dataversemicircles.mat')
N1=500;
c1 = data(1:500,1:2);
N2=500;
c2 = data(501:end,1:2);
plot(c1(:,1),c1(:,2),'ro');
hold on
%%%%%%%%%%%
plot(c2(:,1),c2(:,2),'bo');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dist=@(z,x) sum(abs(x-z).^2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x2=-25:1:25;
x1=-25:1:25;
for k=1:length(x1)
if mod(k,10)==0
k
end
for j=1:length(x2)
xtest=[x1(k),x2(j)];
for i=1:N1
d1(i)=dist(xtest,c1(i,:));
end
for i=1:N2
d2(i)=dist(xtest,c2(i,:));
end
% MODIFICANDO ESTOS PARAMETROS PODEMOS VER LOS DIFERENTES RESULTADOS
L1=1;
L2=200;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DIM=2;
K1=(1/(sqrt(2*pi*L1).^2))^DIM*exp(-d1/(2*L1^2));
K2=(1/(sqrt(2*pi*L2).^2))^DIM*exp(-d2/(2*L2^2));
P1=mean(K1);
P2=mean(K2);
probC1(k,j) = (P1/(P1+P2));
probC2(k,j) = (P2/(P1+P2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if P1>P2
dec=1;
plot(xtest(1,1),xtest(1,2),'r.','LineWidth',2,'MarkerSize',10)
elseif P1<P2
dec=0;
plot(xtest(1,1),xtest(1,2),'b.','LineWidth',2,'MarkerSize',10)
else
plot(xtest(1,1),xtest(1,2),'g.','LineWidth',2,'MarkerSize',10)
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
pc1 = transpose(probC1);
pc2 = transpose(probC2);
pcolor(pc1);
figure
pcolor(pc2);