# \[Solved\] Fit TH1D with Poisson Function

**URL:** <https://root-forum.cern.ch/t/solved-fit-th1d-with-poisson-function/29886>\
**Category:** ROOT\
**Created:** [July 20, 2018, 9:42am UTC](https://root-forum.cern.ch/t/solved-fit-th1d-with-poisson-function/29886 "2018-07-20T09:42:54Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [July 20, 2018, 10:41am UTC](https://root-forum.cern.ch/t/solved-fit-th1d-with-poisson-function/29886/6 "2018-07-20T10:41:28Z")

</div>

I think the problem is in the “x range” of your histogram. From your picture, I can see that “x\_max = 10.e-6” and the [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution) expects “x\_max \>= 1” (so, in principle you should also have “mean \>= 0.5”).  
You could try to “scale” your “x range”:

```auto
{
  double xmin = 0.;
  double xmax = 10.e-6;
  TF1 *f = new TF1("f", "[0] * TMath::Poisson((x/[2]), ([1]/[2]))", xmin, xmax);
  double constant = 160.;
  double mean = 1.5e-6;
  double xscaling = 2.e-7;
  f->SetParameters(constant, mean, xscaling);
  f->SetParNames("Constant", "Mean", "XScaling");
  f->SetNpx(1000);
  f->Draw();
  double integral = f->Integral(xmin, xmax);
  std::cout << "integral = " << integral << std::endl;
  std::cout << "scaled integral (constant) = " << integral / xscaling << std::endl;
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/solved-fit-th1d-with-poisson-function/29886)._
