# How to use TKDE for smoothing an histogram?

**URL:** <https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946>\
**Category:** ROOT\
**Created:** [October 2, 2018, 2:57pm UTC](https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946 "2018-10-02T14:57:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atd](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/atd/32/33835_2.png) [@atd](https://root-forum.cern.ch/u/atd)\
**Post date:** [October 2, 2018, 2:57pm UTC](https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946/1 "2018-10-02T14:57:30Z")

</div>

Dear rooters,

I would like to use a smooth version of binned data (the shape is roughtly a “Lorentzian + constant”). I noticed that the class TKDE could be used for that. Is there a way to provide binned data to the TKDE object?

Thank you in advance.

Best regards,  
atd

* * *

_ROOT Version:_ 6.10  
_Platform:_ CC7  
_Compiler:_ gcc 4.8

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 2, 2018, 3:02pm UTC](https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946/2 "2018-10-02T15:02:17Z")

</div>

Did you already took a look at the `$(ROOTSYS)/tutorials/math/exampleTKDE.C` tutorial?

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 2, 2018, 5:21pm UTC](https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946/3 "2018-10-02T17:21:08Z")

</div>

It doesn’t really make sense to provide binned data to a KDE. A KDE typically places a kernel (usually a Gaussian) centered at each data point. The smoothed distribution is then constructed from the sum of these kernels. By providing binned data you limit the final resolution of the smooth distribution. Is there a problem with providing the full data set?

Also, there is a signature that allows for a weighting at each data point that should work:  
[https://root.cern.ch/doc/master/classTKDE.html#af679eafd086f04e8b829a7b93b2166b4](https://root.cern.ch/doc/master/classTKDE.html#af679eafd086f04e8b829a7b93b2166b4)

---

<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:** [October 16, 2018, 5:21pm UTC](https://root-forum.cern.ch/t/how-to-use-tkde-for-smoothing-an-histogram/30946/4 "2018-10-16T17:21:09Z")

</div>

Closed on October 16, 2018, 5:21pm UTC

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