% Example: [Xp,Xn] = data_semi_circle(10,5,-1,400,42,4);
% Written by W.-S. Lu, University of Victoria.
% Last modified: Nov. 23, 2021.
function [xp,xn] = data_semi_circle(r,thk,sep,N,st1,st2)
r1 = r;
r2 = r + thk;
ku = 0;
xp = [];
randn('state',st1)
while ku < N
    xw = 12*randn(2,1);
    cr = 0;
    xm = norm(xw);
    if xm < r2 & xm > r1
       cr = cr + 1;
    end
    if xw(2) > 0
       cr = cr + 1;
    end
    if cr == 2
       xp = [xp xw];
       ku = ku + 1;
    end
end
kd = 0;
xn = [];
randn('state',st2)
while kd < N
    xw = 12*randn(2,1);
    cr = 0;
    xm = norm(xw);
    if xm < r2 & xm > r1
       cr = cr + 1;
    end
    if xw(2) < 0
       cr = cr + 1;
    end
    if cr == 2
       xn = [xn xw];
       kd = kd + 1;
    end
end
ra = 0.5*(r1+r2);
xn(1,:) = xn(1,:) + ra;
xn(2,:) = xn(2,:) - sep;
figure(1)
clf
plot(xp(1,:),xp(2,:),'ko')
hold on
plot(xn(1,:),xn(2,:),'k+')
grid
xlabel('\itx_1')
ylabel('\itx_2')
axis([-20 30 -20 20])
axis square
hold off