F
Francogrex
Hi again, with a new question (beginner have a lot to learn). I am
doing an updating algorithm where I have to do 10 iterations and each
time need to replace the values of the matrix theta by the new
estimated thetaNew matrix, but it doesn't seem to be working, there is
no interative replacement, the values should end up being
0.6971233
0.09863044
0.1357830
0.06846318
but they're stuck at:
0.611544
0.0858034
0.146646
0.0733229
Thanks for any suggestion correction. The code below:
#include <iostream>
using namespace std;
int main(){
double xa[3][3]={{392.0,55.0},{76.0,38.0}};
double xb[3][3]={{0,0},{33,9}};
double xc[3][3]={{31.0,7.0},{0,0}};
double theta[3][3]={{0.25,0.25},{0.25,0.25}};
double n=641.0;
double thetaNew[3][3]={{0.25,0.25},{0.25,0.25}};
int k=0;
int i=0,j=0;
while (k<10){
for (i=0;i<2;i++){
for (j=0;j<2;j++){
thetaNew[j]=((xa[j])+(((xb[1]))*theta[j]/(theta
[1]+theta[2]))+
(((xc[1][j]))*theta[j]/(theta[1][j]+theta[2][j])))/n;
}
}
for (i=0;i<2;i++){
for (j=0;j<2;j++){
theta[j]=thetaNew[j];
}
}
k=k+1;
cout<<"iteration: "<<k<<"\n";
}
for (i=0;i<2;i++){
for (j=0;j<2;j++){
cout <<"" <<thetaNew[j]<<"\n";
}
}
system("PAUSE");
return 0;
}
doing an updating algorithm where I have to do 10 iterations and each
time need to replace the values of the matrix theta by the new
estimated thetaNew matrix, but it doesn't seem to be working, there is
no interative replacement, the values should end up being
0.6971233
0.09863044
0.1357830
0.06846318
but they're stuck at:
0.611544
0.0858034
0.146646
0.0733229
Thanks for any suggestion correction. The code below:
#include <iostream>
using namespace std;
int main(){
double xa[3][3]={{392.0,55.0},{76.0,38.0}};
double xb[3][3]={{0,0},{33,9}};
double xc[3][3]={{31.0,7.0},{0,0}};
double theta[3][3]={{0.25,0.25},{0.25,0.25}};
double n=641.0;
double thetaNew[3][3]={{0.25,0.25},{0.25,0.25}};
int k=0;
int i=0,j=0;
while (k<10){
for (i=0;i<2;i++){
for (j=0;j<2;j++){
thetaNew[j]=((xa[j])+(((xb[1]))*theta[j]/(theta
[1]+theta[2]))+
(((xc[1][j]))*theta[j]/(theta[1][j]+theta[2][j])))/n;
}
}
for (i=0;i<2;i++){
for (j=0;j<2;j++){
theta[j]=thetaNew[j];
}
}
k=k+1;
cout<<"iteration: "<<k<<"\n";
}
for (i=0;i<2;i++){
for (j=0;j<2;j++){
cout <<"" <<thetaNew[j]<<"\n";
}
}
system("PAUSE");
return 0;
}