# Understanding NBD Fit parameters

**URL:** <https://root-forum.cern.ch/t/understanding-nbd-fit-parameters/62818>\
**Category:** Newbie\
**Created:** [February 4, 2025, 4:20pm UTC](https://root-forum.cern.ch/t/understanding-nbd-fit-parameters/62818 "2025-02-04T16:20:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [February 4, 2025, 4:20pm UTC](https://root-forum.cern.ch/t/understanding-nbd-fit-parameters/62818/1 "2025-02-04T16:20:56Z")

</div>

_ROOT Version:_ 6.32.04  
_Platform:_ WSL2 Ubuntu

Hello! I am performing an NBD fit to a charged hadron multiplicity curve. I define a fit function:

```
// Fitting function
TF1 *fist = new TF1("fist", "[0]*ROOT::Math::negative_binomial_pdf([1],[2],x)", 0, 60);

```

And then perform the fit with initial guesses for the variables.

```
// Input fit params
fist->SetParameter(0,1); // normalisation parameter
fist->SetParameter(1,15); // k - shape parameter
fist->SetParameter(2,0.5); // p - probability parameter
// Perform fitting
hist->Fit("fist", "R0");

```

My doubts:

1 - As I understand the documentation, the `negative_binomial_pdf` accepts `(k,p,n)` respectively. Initially, I kept `n` as a parameter (by setting it to [3]). However, this did not work. After tweaking, I observed that setting `n` as `x` solves the issue. But I do not understand why?

2 - Is there a way to improve the fit further? Provided the plot below for reference.

 ![a0f184a4-b2f1-490a-8c33-f217d2feecd4](https://root-forum.cern.ch/uploads/default/original/3X/8/1/81c13f1a11534dd7f1f856576474681dda0646fd.jpeg)

Looking forward to any inputs since I am still new to ROOT. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [February 5, 2025, 7:30am UTC](https://root-forum.cern.ch/t/understanding-nbd-fit-parameters/62818/2 "2025-02-05T07:30:18Z")

</div>

Hello,

Thanks for the post and welcome to ROOT’s Community!  
Interesting LEP fit.

1. The fit procedure leads to estimates of the parameters values and uncertainties: how you set it up (what are variables or parameters is up to you)
2. Hard to say… Depends on many factors: try to inspect the output of the minimizer to see if the fit converged correctly, for example.

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [February 5, 2025, 1:15pm UTC](https://root-forum.cern.ch/t/understanding-nbd-fit-parameters/62818/3 "2025-02-05T13:15:00Z")

</div>

Hi @Danilo,

Thanks for the response! I have a few follow-ups:

1 - To rephrase, do you perhaps know why using `[0]*ROOT::Math::negative_binomial_pdf([1],[2],[3])` leads to the bad fit result shown below,

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/8/2/824c69eb0395bfdc1f49167a5703100651de1c82.jpeg)

… while using `[0]*ROOT::Math::negative_binomial_pdf([1],[2],x)` solves the issue?

As per the literature, using `k,n` as parameters for nCh curves is best. However, the only definition that works for me in ROOT requires n as an independent variable and `k,p` to be set.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/5/2/52b47546ecd47033682707a29297c09cd948b7ce.png)  
(from a Los Alamos paper, can’t add a link as a new user)

2 - I will check this out, thank you.

Hope the question is clearer now. I want to build a qualitative understanding of how to use variables and parameters.

Cheers, Philip
