# Fitting two data sets to a third

**URL:** <https://root-forum.cern.ch/t/fitting-two-data-sets-to-a-third/44475>\
**Category:** Newbie\
**Created:** [April 19, 2021, 7:14pm UTC](https://root-forum.cern.ch/t/fitting-two-data-sets-to-a-third/44475 "2021-04-19T19:14:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nimatatari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nimatatari/32/25611_2.png) [@nimatatari](https://root-forum.cern.ch/u/nimatatari)\
**Post date:** [April 19, 2021, 7:14pm UTC](https://root-forum.cern.ch/t/fitting-two-data-sets-to-a-third/44475/1 "2021-04-19T19:14:21Z")

</div>

Hi everyone,

Inexperienced with data analysis, I am trying to fit a multiple set of calculated data points (as my fitting functions) to another single set of data points. Therefore, I would not need to use any mathematical polynomial or functions for my fitting. What I need in the end is a set of weighting factors that give the best fit.

So, for example, I have data points of f1(x) and f2(x), and also the target data points F(x). I need to calculate the double numbers w1 and w2 in  
w1.f1(x) + w2.f2(x) so that this combination gives the best fit to F(x)

I would appreciate it if anyone helps me understand if there is such functionality within Root.

Best regards,  
Nima

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [April 22, 2021, 8:00am UTC](https://root-forum.cern.ch/t/fitting-two-data-sets-to-a-third/44475/2 "2021-04-22T08:00:34Z")

</div>

Perhaps @moneta can give a hand here? Thanks!

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [April 22, 2021, 8:36am UTC](https://root-forum.cern.ch/t/fitting-two-data-sets-to-a-third/44475/3 "2021-04-22T08:36:13Z")

</div>

Hi,

You can look at this tutorial for example : [ROOT: tutorials/fit/FittingDemo.C File Reference](https://root.cern.ch/doc/master/FittingDemo_8C.html)  
where a fit to a signal and background distributiun is performed.  
If you want to interpret the fitted coefficients as number of events, you can then look also at this one:  
[ROOT: tutorials/fit/fitNormSum.C File Reference](https://root.cern.ch/doc/master/fitNormSum_8C.html)

If you have further questions, please let us know

Cheers

Lorenzo
