void hwe::estHWE(double *x,double *loglike,int nInd){ double l=HWE_like(x,loglike,nInd); int iter=50; double d=l; int printer=0; for(int i=0;i<iter;i++){ HWE_EM(x,loglike,nInd); l=HWE_like(x,loglike,nInd); if(d>l+0.01){ // fprintf(stderr,"d %f\tl %f\n",d,l); printer=1; } d=l; } if(printer & 0){ x[0]=0.05; x[1]=0.05; l=HWE_like(x,loglike,nInd); for(int i=0;i<iter;i++){ fprintf(stderr,"like %d\t%f\tf %f\tF %f\t%d\n",i,l,x[0],x[1],nInd); HWE_EM(x,loglike,nInd); l=HWE_like(x,loglike,nInd); } for(int ind=0;ind<nInd;ind++){ fprintf(stdout,"likes %f, %f, %f\n",loglike[ind*3+0],loglike[ind*3+1],loglike[ind*3+2]); } fflush(stderr); exit(0); } //print here // fprintf(stderr,"like %d\t%f\tf %f\tF %f\t%d\n",iter,l,x[0],x[1],nInd); }
void abcHWE::estHWE(double *x,double *loglike,int nInd){ double y[2];// = new double[2]; y[0] = x[0]+2; y[1] = x[1]+2; int iter=50; double dif; //fprintf(stderr,"%f\n",differ(x,y)); int printer=0; for(int i=0;i<iter;i++){ HWE_EM(x,loglike,nInd); dif = differ(x,y); // fprintf(stderr,"%f\n",dif); if(dif<tolStop) break; y[0] = x[0]; y[1] = x[1]; } }