EM算法matlab,或者是算法的程序(只要输入data数据便能出结果的哪种,)或者是写出具体的运行步骤。3q
发布网友
发布时间:2022-04-29 10:24
我来回答
共1个回答
热心网友
时间:2023-10-14 05:49
x=VarName2';
length=size(x,2);
pi0=0.4;
p0=0.6;
q0=0.7;
pi=zeros(1,length);
a=zeros(1,length); %mu和xi的乘积
b=zeros(1,length); %1-mu和xi的乘积
p1=zeros(1,length);
p2=zeros(1,length);
mu=zeros(1,length);
for i=1:length %i从1开始
mu(i)=(pi0*(p0.^x(i)))*((1-p0).^(1-x(i)))/((pi0*(p0.^x(i)))*((1-p0).^(1-x(i)))+((1-pi0)*(q0.^x(i)))*((1-q0).^(1-x(i))));
a(i)=mu(i)*x(i);
b(i)=(1-mu(i))*x(i);
end
pi=sum(mu)/length
p1=sum(a)/sum(mu)
p2=sum(b)/sum(1-mu)