5 #include "Math/GSLMinimizer.h"
6 #include "Math/Functor.h"
13 Peak(
const Model * m,
int maxx=0): model(m), pr(m->generateparameters(maxx)), max(maxx){
14 lmax=model->likelihood(pr);
18 llmax=model->loglike(pr,1,max);
24 for(
uint i=1e5;i;i--){
29 if(!model->veto(p1,max)){l1=model->loglike(p1,1,max);
31 if(l1>llmax){pr=p1; llmax=l1; f=fixed;}
32 else {f--;
if(!f) {d/=100; f=fixed;
if(d<1e-2)
break;}}
34 cout<<
"d "<<d<<
"llmax "<<llmax<<endl;
35 if(llmax<-1000) lmax=0;
138 for(
uint i=0;i<pr.size(); i++){
141 double x=(lmax-model->likelihood(p1))*2/lmax/s/s;
142 double x0=std::pow(2/(pr[i].max-pr[i].min),2);
145 pr[i].step=1/sqrt(x);
172 floatPeak=
Peak(model,max);
174 floatPeak.llmax=-1000;
175 cout<<
"started"<<endl;
177 for(
uint i=ns;i;i--){
190 if(pp.
lmax>floatPeak.lmax){
191 cout<<i<<
" "<<pp.
lmax<<endl;
192 floatPeak.lmax=pp.
lmax;
196 floatPeak.
area=floatPeak.pr.area();
201 if(model->r->Rndm()<=0.9) {
202 proposal.pr=floatPeak.pr;
203 proposal.pr.next(model->r);
207 proposal.pr=model->generateparameters();
213 l1=model->likelihood(proposal.pr);
214 if(model->r->Rndm()<=l1/floatPeak.lmax){
216 floatPeak.pr.setvalues(proposal.pr);
Peak(const Model *m, int maxx=0)
void findPeaks(uint ns=1, int max=0)
Abstract class for a model.
A class containing the parameters of a maximum of the likelihood function.
void next(TRandom3 *r, double f=1)
changes randomly the value of the parameters
A class containing the parameters of a proposal for the next step in the Markov Chain.