2012-09-20 66 views
3

欲用于产生n随机数假设为高斯分布,给出的以下输入的MATLAB程序:高斯分布

  • 2个装置(x和y轴)
  • 标准偏差
  • 方差(协方差矩阵=标准差x单位矩阵)
+0

什么是你的问题,建立对正态分布数据的(x,y)?这听起来像可能是我们为你做功课的要求。 –

回答

1

如果你没有进入统计工具箱,您可以使用randn

%# create an array of 100 pairs of normally distributed 
%# coordinates with mu=0 and sigma=1 

xy = randn(100,2); 

%# transform the data such that means equal mu 
%# and standard deviations equal sigma (no cross-correlation) 

mu = [3,25]; %# means for x, y 
sigma = [9,1]; % standard deviations for x,y 

xy = bsxfun(@times,xy,sigma); %# fix standard deviation 
xy = bsxfun(@plus,xy,mu); %# fix means