.. _book_fig_chapter6_fig_hist_to_kernel: Histogram vs Kernel Density Estimation -------------------------------------- Figure 6.1 Density estimation using histograms and kernels. The top panels show two histogram representations of the same data (shown by plus signs in the bottom of each panel) using the same bin width, but with the bin centers of the histograms offset by 0.25. The middle-left panel shows an adaptive histogram where each bin is centered on an individual point and these bins can overlap. This adaptive representation preserves the bimodality of the data. The remaining panels show kernel density estimation using Gaussian kernels with different bandwidths, increasing from the middle-right panel to the bottom-right, and with the largest bandwidth in the bottom-left panel. The trade-off of variance for bias becomes apparent as the bandwidth of the kernels increases. .. rst-class:: horizontal .. image:: ../images/chapter6/fig_hist_to_kernel_1.png :align: center :scale: 100 .. image:: ../images/chapter6/fig_hist_to_kernel_2.png :align: center :scale: 100 .. raw:: html
**Code output:** .. raw:: html
.. literalinclude:: fig_hist_to_kernel.txt .. raw:: html
**Python source code:** .. raw:: html
.. literalinclude:: fig_hist_to_kernel.py :lines: 18- .. raw:: html
:download:`[download source: fig_hist_to_kernel.py] ` .. raw:: html