Integral function over parameter

Dear all,

I’m trying to implement an integral function for fitting. The function is one dimensional with the integration over one parameter, for example:

y(x) = Integral_{aMin}^{aMax} da f(x,a)

Can you help me?

Thanks,

Renato

Hi,

You can create a TF1 object based on an integral function. An example for this is the tutorial
exampleFunctor.C

https://root.cern.ch/doc/master/exampleFunctor_8C.html

Best Regards

Lorenzo

Hi Lorenzo,

I had seen this example before, and if I understood it correctly, it’s an integration over x with fixed parameters. I was wondering if there is a way to define a TF2 and integrate over the first variable.

Thanks,

Renato

Hi,

The Functor class can wrap in the way you want. You can define a TF1 where x are the parameter you want to integrate and the wrap with the functor to create another TF1 which uses as x a parameter of the internal TF1. Here is an example using the lambda as functor

auto f1 = new TF1("f1","sin( [0]*x)",0,10);
// define now the integral function
double pmin=1; 
double pmax = 5; 
auto fint = [&] (double *x, double *p){ f1->SetParameter(0,x[0]); return f1->Integral(pmin,pmax); }
auto f2 = new TF1("f2",fint, 0,10, 1);

Cheers

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.