% CmpInit.m % A.P. Paplinski 27 August 2004 % Initialisation of competitive learning % Generation of a 2-D pattern consisting of m clusters % of normally distributed points clear p = 2; m = 5 ; % p inputs, m outputs clst = randn(p, m); % cluster centroids clst = [1 2 4 6 5 5 1 4 2 6] ; Nk = 20; % points per cluster N = m*Nk ; % total number of points sprd = 0.5 ; % a relative spread of the Gaussian "blob" X = zeros(p,N+m); % X is p by m+N input data matrix wNk = ones(1, Nk); for k = 1:m xc = clst(:,k) ; X(:,(1+(k-1)*Nk):(k*Nk)) = sprd*randn(p,Nk)+xc(:,wNk) ; end [xc k] = sort(rand(1,N+m)); X = X(:, k) ; % input data is shuffled randomly Win = X(:,1:m)'; % Initial values of weights X = X(:,m+1:N+m); % figure(1), clf reset % plot(X(1, :), X(2, :), 'g.', Win(:, 1), Win(:, 2), 'b^', ... % clst(1, :), clst(2, :), 'ro' ), grid on, % title('Afferent data'), xlabel('x_1'), ylabel('x_2')