生成具有正常均值的多维法向向量(matlab)

时间:2018-07-07 11:08:39

标签: matlab normal-distribution

嗨 考虑这种情况: 我们想正常生成一个样本数据。但是这里我们要生成一个来自正态分布的数据,其均值也来自正态分布(均值不同)。 (在Matlab中),下面是上述说明的另一种表示形式。

enter image description here

这是我的Matlab代码,但是当我尝试使用此功能的多维版本时出现错误。

mu_a1 = 1         ;
sigma_a1 = .05 ; 
mu_a2 = 1         ;
sigma_a2 = .05 ; 

u_a1 = normrnd(mu_a1,sigma_a1,[1,100]) 

u_a2 = normrnd(mu_a2,sigma_a2,[1,100])  

U_A = [u_a1 , u_a2] ; 
Sigma_A = [.08 0 ; 0 .08] ; 

x_1 = normrnd(u_a1 , .08,[200,1]) ;
x_2 = normrnd(u_a2 , .08,[200,1]) ;
%x_1 = normrnd([0,1] ,.08, 300,2) 
%x_2 = normrnd([0,1] , .08, 300,2)

%size(x_1)  
%size(x_2) 
%normrnd(U_A , Sigma_A) ;

和错误:

Error using normrnd (line 33)
Size information is inconsistent.

我希望您能为在Matlab中生成此类数字提供任何帮助。

0 个答案:

没有答案