Error in TFormula::Compile: Bad numerical expression : "g_Moyal"
Error in TF1::TF1: function: f/g_Moyal has 0 parameters instead of 1
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
Warning in TCanvas::ResizePad: c1 height changed from 64000 to 10
I guess the reason is missing parameter. I changed abit like,
int fit() {
TCanvas *c1 = new TCanvas(“c1”, “asdf”, 1800, 800);
TF1 *f = new TF1(“f”,g_Moyal,-5,10,4);
f->SetParameter(0,140.0);
f->Draw();
}
However afterwards it gave this error,
Error: Function f_Moyal((x[0]-par[1])/par[0]) is not defined in current scope fit.C:344:
*** Interpreter error recovered ***
root [1] Error: Function f_Moyal((x[0]-par[1])/par[0]) is not defined in current scope fit.C:344:
,
Error: Symbol , is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
Double_t f_Moyal(Double_t *xx, Double_t *par) {
auto x = *xx;
auto theexp = TMath::Exp(-0.5*(x+TMath::Exp(-x)));
return theexp / TMath::Sqrt(TMath::TwoPi());
}
Double_t g_Moyal(Double_t *x, Double_t *par) {
double xx = (x[0]-par[0])/par[1];
return f_Moyal(&xx, nullptr)/par[1];
}
void moyal() {
auto f = new TF1("f",g_Moyal,-5,10,2);
f->SetParameters(1,1);
auto c = new TCanvas();
f->Draw();
}