Hello Jeroen,
I’m afraid this is not what TF1::Variance provides. Perhaps you are thinking of something more like TF1::GetChiSquare(), which returns information on the quality of a fitted function to some data points?
I’ll take this as an opportunity to explain TF1::Variance (and a few other member functions I helped write), but I expect this will not be of much help to you. TF1::Variance has nothing to do with any data points. The following member functions provide functionality as:
TF1::Moment(n,a,b)
The nth moment of a function about zero. When n=1, this is the common case of the mean of a function between x=a and x=b. So moment = [Int x^n*f(x)]/[Int f(x)] where Int means the integral from x=a to b.
TF1::CentralMoment(n,a,b)
The nth moment of a function about the mean. So if u is the mean between a and b, the central moment = [Int (x-u)^n*f(x)]/[Int f(x)].
TF1::Variance(a,b) = TF1::CentralMoment(2,a,b)
By definition.
Unfortunately, this code suffers from one major flaw: it uses TF1::Integral to calculate the integrals, but TF1::Integral does not like negative values (it takes the absolute value of a function for its integral). This becomes a problem not only when trying to get the integral of a TF1 function which has negative values, but also when simply trying to get the mean of a function when the range (a,b) spans any negative numbers because x*f(x) can go negative even if f(x) is positive. Maybe one day we can get a version of TF1::Integral which does not take the absolute value of the evaluated function.
Hope that helps!
-Gene