I have got two different kind of data points (x_i, y_i). Because one kind are the result of several measurements of the same object I know their statistical error \Delta x_i, \Delta y_i for x_i and y_i.
(So the data is like (x_{1,1}/y_{1,1}), ( x_{1,2}/y_{1,2}), ..., (x_{1,l}/y_{1,l}) and (x_{2,1} \pm \Delta x_{2,1} /y_{2,1} \pm \Delta y_{2,1} ), ( x_{2,2} \pm \Delta x_{2,2} /y_{2,2} \pm \Delta y_{2,2}), ..., (x_{2,k} \pm \Delta x_{2,k} /y_{2,k} \pm \Delta y_{2,k}))
For the other one I do not now the statistical error. Thus, I am doing 2 separate fits (y_i = a_i \cdot x^2 + b_i \cdot x + c_i with i=1, 2) for the two kinds of data point using \chi^2 fits / Deming regression (fitting to TGraph
/ TGraphErrors
).
Applying just one fit the weight of the data points without error would be too large. Using the individual measurement instead of average + error I would loose the information that they belong to the same object.
Result: a_i, b_i, c_i, \Delta a_i, \Delta b_i, \Delta c_i
Now I want to combine the two fit result to one functions including uncertainties:
y_m = (a_m \pm \Delta a_m) \cdot x^2 + (b_m \pm \Delta b_m) \cdot x + (c_m \pm \Delta c_m)
using weighted mean by using the \frac{1}{\Delta a_i}, \frac{1}{\Delta b_i}, \frac{1}{\Delta c_i} as weights.
Can I just use:
y_m = \frac{\sum_{i=1}^n y_i \cdot \frac{1}{(\Delta y_i)^2}}{\sum_{i=1}^n \frac{1}{(\Delta y_i)^2}}
where \Delta y_i is got by Gaussian error propagation: \Delta y_i = \sum_{j=1}^m \frac{\partial y_i}{\partial p_{j,i}} \cdot \Delta p_{j,i} with p_{1,i} = a_i, p_{2,i} = b_i, p_{3,i} = c_i.
And
\sigma_{y_m}^2 = \frac{1}{\sum_{i=1}^n \frac{1}{\Delta y_i^2} }
As y_m will be a broken rational function (of order 2) and not a polynomial of order 2 anymore and there are no separate errors for the fitted parameters anymore, I hope there is a better way.
Is there something like HypoTestResult
for combining fit result in Root >= 6.24
P.S.: What I do not want to do is just plotting two fits in one TGraph
/ TH1
(as combinedFit.C
example).
I notice that I was doing stupid thing when viewing the 3 fits as a switched from linear fit to quadratic one.
Just calculating the weighted mean of the fitted parameters is not a good idea …