/* doing gridsearch when only one is multiplicative */ proc grids_1(h1,h2,startt,maxt,thmin1,thmax1,dth1); local res, fct, b, adr,ngr1,ptrue,probs,pp1,pp2, theta1; probs=calprobs1(h1,startt,maxt); pp1=probs[.,1]|probs[.,2]; pp1=pp1|(1-sumc(pp1)); probs=calprobs1(h2,startt,maxt); pp2=probs[.,1]|probs[.,2]; pp2=pp2|(1-sumc(pp2)); ptrue=pp1|pp2; ngr1=(thmax1-thmin1)/dth1+2; ngr1=floor(ngr1); theta1=seqa(thmin1,dth1,ngr1); res=1000+zeros(1,4); for ib (1,rows(theta1),1); b=theta1[ib]; adr=hsec; fct= func_1mult(b,maxt,ptrue,2); print /flush fct~-99~b~(hsec-adr); res=res|(fct~-99~b~(hsec-adr)); endfor; retp(res[2:rows(res),.]); endp; proc grid_seq_1(h1,h2,startt,maxt,thmin1,thmax1,dth1); local res,fr,rrr; output on; " "; "first grid"; " "; thmin1~thmax1~dth1; " "; output off; res=grids_1(h1,h2,startt,maxt,thmin1,thmax1,dth1); fr=res[.,1]; fr=unique(fr,1); fr=sortc(fr,1); rrr=selif(res,res[.,1].ge fr[rows(fr)-2]); output on; "first round minimizers"; " "; selif(res,res[.,1].ge maxc(res[.,1])); thmin1=minc(rrr[.,2])-dth1; thmax1=maxc(rrr[.,2])+1.5*dth1; dth1=dth1/5; " "; "second grid"; " "; thmin1~thmax1~dth1; " "; output off; res=res|grids_1(h1,h2,startt,maxt,thmin1,thmax1,dth1); fr=res[.,1]; fr=unique(fr,1); fr=sortc(fr,1); rrr=selif(res,res[.,1].ge fr[rows(fr)-2]); output on; "second round minimizers"; " "; selif(res,res[.,1].ge maxc(res[.,1])); " "; thmin1=minc(rrr[.,2])-dth1; thmax1=maxc(rrr[.,2])+1.5*dth1; dth1=dth1/10; "third grid"; " "; thmin1~thmax1~dth1; " "; output off; res=res|grids_1(h1,h2,startt,maxt,thmin1,thmax1,dth1); output on; "third round minimizers"; " "; selif(res,res[.,1].ge maxc(res[.,1])); " "; output off; retp(res); endp;