matlab迭代循环的问题,这个程序怎么都有错,求好心人士指点错在哪
此程序的目的就是算出迭代次数以及lamda和beta的最后值n1=poissrnd(5,1,5);n2=exprnd(0.005,1,5);x=n1.*n2;m=1;wh...
此程序的目的就是算出迭代次数以及lamda和beta的最后值
n1=poissrnd(5,1,5);
n2=exprnd(0.005,1,5);
x=n1.*n2;
m=1;
while 1
lamda_0=4.5;
beta_0=0.007;
for i=1:5;
a_i=zeros(1,5);
b_i=zeros(1,5);
for j=1:5;
a_i(j)=lamda_(m-1)^j*beta_(m-1)^j*x(i)^(j-1)/factorial(j-1)^2;
b_i(j)=lamda_(m-1)^j*beta_(m-1)^j*x(i)^(j-1)/factorial(j-1)/factorial(j);
end;
sum(a_i);
sum(b_i);
d=zeros(1,5);
d(i)=sum(a_i)./sum(b_i);
lamda_m=1/5*sum(d);
beta_m=lamda_m*5/sum(x);
theta_m=[lamda_m,beta_m];
err=abs(theta_m-theta_(m-1));
if err<0.005
break;
else
m=m+1;
end;
L=lamda_m
B=beta_m 展开
n1=poissrnd(5,1,5);
n2=exprnd(0.005,1,5);
x=n1.*n2;
m=1;
while 1
lamda_0=4.5;
beta_0=0.007;
for i=1:5;
a_i=zeros(1,5);
b_i=zeros(1,5);
for j=1:5;
a_i(j)=lamda_(m-1)^j*beta_(m-1)^j*x(i)^(j-1)/factorial(j-1)^2;
b_i(j)=lamda_(m-1)^j*beta_(m-1)^j*x(i)^(j-1)/factorial(j-1)/factorial(j);
end;
sum(a_i);
sum(b_i);
d=zeros(1,5);
d(i)=sum(a_i)./sum(b_i);
lamda_m=1/5*sum(d);
beta_m=lamda_m*5/sum(x);
theta_m=[lamda_m,beta_m];
err=abs(theta_m-theta_(m-1));
if err<0.005
break;
else
m=m+1;
end;
L=lamda_m
B=beta_m 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询