大概图像如下
其中c1,c2,c3为三个不同的类别,生成数据位于圆内。
实现
代码中考虑了均匀分布以及高斯分布,代码如下
%% 生成圆形点参数
clear; clc;
type = 'gaussian'; % uniform
sigma = 0.6; % var for guassian
p = [1, 2, 3;
1, 3, 1]; % centre of circle
r = [1, 1, 1]; % radius
N = 20; % num of each circle point
n = size(p, 2); % num of centre
% A = zeros(n * N, 2); % matrix for points
A = [];
gnd = []; % gnd for data
for i = 1:n
gnd = [gnd; i * ones(N, 1)];
end
% 开始生成散点图
disp('generate circles.');
switch lower(type)
case {lower('gaussian')}
for i = 1:n
for j = 1:N
while(1)
x = normrnd(p(1, i), sigma);
y = normrnd(p(2, i), sigma);
diff = [x; y] - p(:, i);