我想生成高斯数据集。该数据集包括从四个二维高斯类中随机抽取的总共800个样本,具有以下分布:
我怎样才能用MATLAB做到这一点。 我不是MATLAB的专家!
答案 0 :(得分:4)
以下需要统计工具箱:
% The means of the Gaussians
mu = [-3,0;0,0;3,0;6,0];
% The covariance matrix
sigma = [0.5,0.05;0.05,0.5];
% The mixing proportions of the Gaussians
p = [0.25,0.25,0.25,0.25];
% Make a Gaussian mixture distribution
myMixtureDistribution = gmdistribution(mu,sigma,p);
% Draw random samples from the distribution
myDataSample = myMixtureDistribution.random(800);
答案 1 :(得分:1)
从randn()
开始。
答案 2 :(得分:1)
我发现答案如下: (全部谢谢)
Sigma=[0.5 0.05; 0.05 0.5];
z=mvnrnd([-3 0],Sigma,200);
x=mvnrnd([0 0],Sigma,200);
c=mvnrnd([3 0 ],Sigma,200);
v=mvnrnd([6 0 ],Sigma,200);
samples=[z; x; c; v];
plot(samples(:,1),samples(:,2),'*');