# Landau-gaussian convoluted fit looks weird

**URL:** <https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901>\
**Category:** ROOT\
**Created:** [November 20, 2019, 12:42pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901 "2019-11-20T12:42:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 12:42pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/1 "2019-11-20T12:42:33Z")

</div>

Dear experts,  
When I try to make a langau fit to my histograms, for most of them, the fit works fine but for some of them, I get some strange behaviour which I cannot understand. Please can someone help?

Please have a look at the attached pdf which contains the figures and the fit output.

Kind regards,  
Ruina

[rootforumlangaufit.pdf](https://root-forum.cern.ch/uploads/short-url/fteASe17bO4xg2fKAGrPErTwktb.pdf) (398.8 KB)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 20, 2019, 12:54pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/2 "2019-11-20T12:54:21Z")

</div>

It looks like the “GSigma” can get too big. Try to define this variable as “limited” and set the upper limit to something like 10.

> [@Fit results didn't show on graph](https://root-forum.cern.ch/t/fit-results-didnt-show-on-graph/36425/2):
>
> In ROOT, before you try to fit your graph or histogram, you MUST set “reasonable” initial values for ALL parameters of your function (except for some “built-in” formulas, like “gaus”, for which the standard fit procedure can automatically “guess” them), otherwise the fitting procedure may easily misbehave.

---

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 1:10pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/3 "2019-11-20T13:10:31Z")

</div>

Thanks, I’ll work on that.

Meanwhile, do you know if there is an efficient way to give reasonable parameter values when one is fitting many distributions together? Meaning, say, I need to make these langau fits for energy distributions of ~1k electronic chips, for all of which the distribution is expected to be similar, meaning they peak at the nearly the same position etc. I guess it is possible that the start params for one distribution may not be ideal for the next…? If so, how can I solve this?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 20, 2019, 1:17pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/4 "2019-11-20T13:17:04Z")

</div>

You could “estimate” them (well, maybe not all of them) from:  
[TH1::GetMean](https://root.cern.ch/doc/master/classTH1.html#a3e2fa7eca22330a7f6458e481e6ca0ae)  
[TH1::GetMaximumBin](https://root.cern.ch/doc/master/classTH1.html#abb474ee303d1b44ffdf800803f12c7ad) + [TH1::GetBinCenter](https://root.cern.ch/doc/master/classTH1.html#a0ee88e02b75d885985097dcde0a9eaa1)  
[TH1::GetStdDev](https://root.cern.ch/doc/master/classTH1.html#a31a19244776aca64aab4ee1808f14c32)  
[TH1::Integral](https://root.cern.ch/doc/master/classTH1.html#a919887c7b8431299713ec22e544cc396)  
[TH1::GetMaximum](https://root.cern.ch/doc/master/classTH1.html#a653d76932d3710f5f021be4c5d019167)  
[TH1::GetMaximumBin](https://root.cern.ch/doc/master/classTH1.html#abb474ee303d1b44ffdf800803f12c7ad) + [TH1::GetBinContent](https://root.cern.ch/doc/master/classTH1.html#ac70dcb4082bd510f5aa3e6efeb043f39)

---

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 1:26pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/5 "2019-11-20T13:26:40Z")

</div>

Yes, I had tried them in the past but somehow, they weren’t giving good results in some cases. I’ll try them again…  
Thank you very much for your prompt help. 🙂

---

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 2:47pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/6 "2019-11-20T14:47:49Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> It looks like the “GSigma” can get too big. Try to define this variable as “limited” and set the upper limit to something like 10.

Update:  
I set it to 10 and it works fine for 97 out of a 100 cases.  
For 3, it is at the upper limit.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 20, 2019, 3:05pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/7 "2019-11-20T15:05:59Z")

</div>

So, try to play with these 3 and e.g. set the limit to 15 (or maybe you need to set limits to another variables, too).

---

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 3:47pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/8 "2019-11-20T15:47:38Z")

</div>

Yes, I already tried 15 and it works! Thanks!

However, for the the other histogram (the blue one), I had 6 of them with this warning  
`Warning in <Fit>: Abnormal termination of minimization.`  
and `STATUS:FAILED`  
So I tried changing the start value of MPV to 35. instead of 40. and that resulted in all 6 of them getting fixed 🙂 but a new one (which was fine before) getting bad ☹ . Changing start value to 34. or 36. does not help (infact they make worse the fits for others).

---

<div class="post-metadata">

**Author:** ![Ruina](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Ruina](https://root-forum.cern.ch/u/Ruina)\
**Post date:** [November 20, 2019, 3:55pm UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/9 "2019-11-20T15:55:19Z")

</div>

Failed fit examples… How do I solve this?  
Example 1

```auto
1141 hist1 std dev 26.762
1142 hist1 mean 47.0601
1143 hist1 integral 794
1144 FCN=243.635 FROM MIGRAD STATUS=FAILED 566 CALLS 567 TOTAL
1145 EDM=0.523113 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 10.5 per cent
1146 EXT PARAMETER APPROXIMATE STEP FIRST
1147 NO. NAME VALUE ERROR SIZE DERIVATIVE
1148 1 Width 1.27874e-02 2.39655e-04 0.00000e+00 -1.51826e+02
1149 2 MP 1.30452e+01 6.92787e-04 0.00000e+00 -1.08202e+06
1150 3 Area 1.33779e+04 2.59424e+03 0.00000e+00 2.15953e+00
1151 4 GSigma 9.99316e+00 3.68144e-04 -0.00000e+00 1.71252e+02

```

Example 2

```auto
25603 hist1 std dev 24.9358
25604 hist1 mean 51.7143
25605 hist1 integral 14599
25606 FCN=293.288 FROM MIGRAD STATUS=FAILED 246 CALLS 247 TOTAL
25607 EDM=10738.8 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent
25608 EXT PARAMETER APPROXIMATE STEP FIRST
25609 NO. NAME VALUE ERROR SIZE DERIVATIVE
25610 1 Width 3.16788e+00 6.53764e+00 0.00000e+00 -2.99869e+02
25611 2 MP 3.87556e+01 6.08231e+04 -0.00000e+00 2.87698e+04
25612 3 Area 1.48061e+04 5.61181e+05 -0.00000e+00 1.87737e+02
25613 4 GSigma 9.40323e+00 7.00875e+00 -0.00000e+00 1.30095e+02

```

The errors are quite large and I don’t know why the step size is zero for all the parameters!

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [November 25, 2019, 10:03am UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/10 "2019-11-25T10:03:37Z")

</div>

Hi,

Finding good initial values is the most tricky part in minimization / fitting: it can determine success or failure and can change the result. I don’t think we have any generic recommendations here; this depends too much on the actual problem / distribution. So indeed your best option is likely to take these distributions and use the fit panel (right click the histogram in a pad) to come up with good initial parameter values for a landau distribution.

Axel.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [December 9, 2019, 10:03am UTC](https://root-forum.cern.ch/t/landau-gaussian-convoluted-fit-looks-weird/36901/11 "2019-12-09T10:03:41Z")

</div>

Closed on December 9, 2019, 10:03am UTC

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