Making progress on MATLAB fitgmdist for Gaussian Mixture models, but still getting error :(
Making progress on MATLAB fitgmdist for Gaussian Mixture models, but still getting error :(
你好堆栈溢出家族。我一直在试图弄清楚如何在 MATLAB 上使用这个讨厌的 fitgmdist 来拟合高斯混合模型。我已经取得了进步,但在尝试设置初始参数时仍然出现错误。我收到以下错误:
当'SharedCovariance'为
错误的。每页必须是一个方阵,其列数与 X 相同,如果
'CovarianceType'是'full',或者长度等于
如果 'CovarianceType' 是 'diagonal'.
,则 X 中的列
代码:
x=rand(5,1);
x=transpose(transpose(x));
y= sum (x);
x=x./y;
a=zeros(10000,1);
b=[1;2;3;4;5];
c=[1;2;4;8;16];
i=1;
for i=1:10000
a(i,1)=rand();
end
S = struct('mu',b,'Sigma',c,'ComponentProportion',x)
GMModel=fitgmdist(a,5,'Start', S)
我使用的是从 unif(0,1) 分布生成的 10000 个数字的随机数据集,假定的初始比例也是从 5 个随机数生成的,表示 1、2、3、4 和 5 以及西格玛 1、2、4、8、16。谢谢!
问题出在您的结构 S 中,如错误消息中所述,协方差矩阵应该有 5 页。解决方案示例:
...
c=zeros(1,1,5);
c(1,1,:) = [1;2;4;8;16];
...
你好堆栈溢出家族。我一直在试图弄清楚如何在 MATLAB 上使用这个讨厌的 fitgmdist 来拟合高斯混合模型。我已经取得了进步,但在尝试设置初始参数时仍然出现错误。我收到以下错误:
当'SharedCovariance'为 错误的。每页必须是一个方阵,其列数与 X 相同,如果 'CovarianceType'是'full',或者长度等于 如果 'CovarianceType' 是 'diagonal'.
,则 X 中的列代码:
x=rand(5,1);
x=transpose(transpose(x));
y= sum (x);
x=x./y;
a=zeros(10000,1);
b=[1;2;3;4;5];
c=[1;2;4;8;16];
i=1;
for i=1:10000
a(i,1)=rand();
end
S = struct('mu',b,'Sigma',c,'ComponentProportion',x)
GMModel=fitgmdist(a,5,'Start', S)
我使用的是从 unif(0,1) 分布生成的 10000 个数字的随机数据集,假定的初始比例也是从 5 个随机数生成的,表示 1、2、3、4 和 5 以及西格玛 1、2、4、8、16。谢谢!
问题出在您的结构 S 中,如错误消息中所述,协方差矩阵应该有 5 页。解决方案示例:
...
c=zeros(1,1,5);
c(1,1,:) = [1;2;4;8;16];
...