How to fit a TF1 to another TF1?

Is it possible to fit a TF1 to another TF1 function in root?

The background story of this question is the following:
I want to use the TKDE module to estimate the underlying density function of some low event count data since generating histograms and fitting to them mostly produces nonsense.
The data basically forms two peaks within a relatively flat noise.
By using TKDE and calling TKDE::GetFunction() I get a TF1 that appears to be very satisfying. However, this is not a parametric function so I can’t read out anything that one would need e.g. to compute a significance.
Hence I would like to perform a fit to this function with a known parametric function (e.g. Gaussian + polynomial), so I may get the values I need.

Is this somehow possible or is there any other way to obtain certain parameters from the TKDE generated TF1?

If there isn’t, the only workaround I see here is to generate a new histogram with very tight binning, fill it with as many as possible entries according to the TKDE generated density function and then perform an ordinary fit.

Any suggestions?

Kind Regards,


Normally the correct thing to do is to fit the original data set that you used as input to the TKDE.
However, TKDE returns also a TGraphErrors with the density estimate and their errors, see

The problem however is that the error in the different points are not uncorrelated, so you should be careful in fitting those data.

Best Regards