# How to fit TH2D histogram with TF2 function?

**URL:** <https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343>\
**Category:** ROOT\
**Tags:** python, hist, root, math\
**Created:** [November 13, 2022, 1:10pm UTC](https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343 "2022-11-13T13:10:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SAYAN\_CHATTERJEE](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayan_chatterjee/32/21843_2.png) [@SAYAN\_CHATTERJEE](https://root-forum.cern.ch/u/SAYAN_CHATTERJEE)\
**Post date:** [November 13, 2022, 1:10pm UTC](https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343/1 "2022-11-13T13:10:14Z")

</div>

Hi Experts,

I am trying to fit the TH2D histogram using TF2 functions. I could not find any good examples related to that. If you know some examples, please share them with me. It would be helpful for me.

Thanks & Regards,  
Sayan

---

<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 13, 2022, 2:14pm UTC](https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343/2 "2022-11-13T14:14:20Z")

</div>

Just define a [TF2](https://root.cern/doc/master/classTF2.html) and fit your [TH2](https://root.cern/doc/master/classTH2.html) as usual.

[`grep -r T[FH]2 ${ROOTSYS}/tutorials/fit`](https://root.cern/doc/master/group __tutorial__ fit.html)

---

<div class="post-metadata">

**Author:** ![SAYAN\_CHATTERJEE](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayan_chatterjee/32/21843_2.png) [@SAYAN\_CHATTERJEE](https://root-forum.cern.ch/u/SAYAN_CHATTERJEE)\
**Post date:** [November 15, 2022, 6:54am UTC](https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343/3 "2022-11-15T06:54:52Z")

</div>

Thanks, Wile. It worked.

---

<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:** [November 29, 2022, 6:55am UTC](https://root-forum.cern.ch/t/how-to-fit-th2d-histogram-with-tf2-function/52343/4 "2022-11-29T06:55:49Z")

</div>

Closed on November 29, 2022, 6:55am UTC

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