我想要一个 MATLAB 程序来生成n
假设高斯分布的随机数,给定以下输入:
- 2 表示(对于 x 和 y 轴)
- 标准差
- 方差(协方差矩阵 = 标准差 x 单位矩阵)
高斯分布的另一个词是正态分布。多维有时也称为多变量。因此请参阅:Matlab 中的多元正态分布。
如果您无权访问统计工具箱,您可以使用创建(x,y)
正态分布数据对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