# How to draw a Gaussian

**URL:** <https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715>\
**Category:** Newbie\
**Created:** [April 22, 2019, 6:28pm UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715 "2019-04-22T18:28:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IP25](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ip25/32/22277_2.png) [@IP25](https://root-forum.cern.ch/u/IP25)\
**Post date:** [April 22, 2019, 6:28pm UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715/1 "2019-04-22T18:28:02Z")

</div>

Hey everyone,

I had a silly question. I have all the parameters for a gaussian distribution, the mean, the standard deviation as well as its the area under curve. I am trying to recreate the gaussian with my specific parameters, how can i do that?

---

<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 23, 2019, 7:12am UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715/2 "2019-04-23T07:12:38Z")

</div>

Hi,

if you have area, mean and sigma, your corresponding function in ROOT is:

`auto f1 = new TF1("f1","area * ROOT::Math::normal_pdf(x, sigma, mean) ", xmin, xmax);`

You can also express in terms of parameters by doing instead

`auto f1 = new TF1("f1","[area] * ROOT::Math::normal_pdf(x, [sigma], [mean]) ", xmin, xmax);`  
`f1->SetParameter("area",area_value);`  
`f1->SetParameter("mean",mean_value);`  
`f1->SetParameter("sigma",sigma_value);`

Lorenzo

---

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [December 9, 2022, 6:40am UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715/3 "2022-12-09T06:40:51Z")

</div>

How to store/convert this function as a histogram ?

---

<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:** [December 9, 2022, 8:04am UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715/4 "2022-12-09T08:04:54Z")

</div>

Hi,  
See [`TF1::GetHistogram`](https://root.cern.ch/doc/master/classTF1.html#a16926c77f916376d4781c037fd5aae17),

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [December 9, 2022, 11:40am UTC](https://root-forum.cern.ch/t/how-to-draw-a-gaussian/33715/5 "2022-12-09T11:40:27Z")

</div>

Thanks Lorenzo!
