我想生成一个高斯数据集。该数据集包括从四个二维高斯类中随机抽取的总共 800 个样本,分布如下:
我怎么能用 MATLAB 做到这一点。我不是MATLAB专家!
以下需要统计工具箱:
% 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);
开始randn()
。
我找到了如下答案:(谢谢大家)
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),'*');