# Could someone help me understand the codes?

**URL:** <https://root-forum.cern.ch/t/could-someone-help-me-understand-the-codes/62017>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [October 25, 2024, 2:57pm UTC](https://root-forum.cern.ch/t/could-someone-help-me-understand-the-codes/62017 "2024-10-25T14:57:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WeiZheng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/b77776/32.png) [@WeiZheng](https://root-forum.cern.ch/u/WeiZheng)\
**Post date:** [October 25, 2024, 2:57pm UTC](https://root-forum.cern.ch/t/could-someone-help-me-understand-the-codes/62017/1 "2024-10-25T14:57:20Z")

</div>

Here are the codes:

| | TCanvas \*c=new TCanvas(c,name,600,600); |
| --- | --- |
| | TH2F \*histo2=new TH2F(histo2,name,20,0,20,20,0,20); |
| | TF2 \*dist=new TF2(dist,[0]+[1]\*x+[2]\*y,0,20,0,20); |
| | dist-\>SetParameters(1,0,0); |
| | histo2-\>FillRandom(dist,40000); |
| | histo2-\>SetMinimum(0); |
| | histo2-\>Draw(LEGO2); |

the output was saved as an image attached. How can I understand the value of each bar? why the mean x is almost 10?

 ![Screenshot from 2024-10-25 10-38-01](https://root-forum.cern.ch/uploads/default/original/3X/c/c/ccb12519473b7f6295971813ba0e7001537d5fb1.png)

Thanks for your help.

_ROOT Version:_ 6.32  
\_Platform: Ubuntu  
\_Compiler:\_g++

W

---

<div class="post-metadata">

**Author:** ![dwielane](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dwielane/32/12354_2.png) [@dwielane](https://root-forum.cern.ch/u/dwielane)\
**Post date:** [October 25, 2024, 9:38pm UTC](https://root-forum.cern.ch/t/could-someone-help-me-understand-the-codes/62017/2 "2024-10-25T21:38:02Z")

</div>

Hi,  
TH2F is a [histogram](https://en.wikipedia.org/wiki/Histogram) the mean x it is an mean value of value x in the histogram.  
I suppose that you expected to get ~110, but this is not a mean x but an average number of entries per bin - something what is on Z axis.
