Course contentsShow
← Data Science
Lesson 1177 of 2,14530. Exploratory Data Analysis (EDA) ProcessFree lesson

Density Plots and KDE

Creating kernel density estimates to show smooth continuous distribution approximations.

Density Plots and KDE

You'll learn how to create smooth, continuous curves that reveal the shape of your data's distribution better than blocky histograms.

What is KDE?

Kernel Density Estimation (KDE) is a technique that creates a smooth curve approximating your data's probability distribution. While histograms divide data into bins creating a jagged appearance, KDE treats each data point as the center of a small "bell curve" (kernel), then sums all these curves to produce one flowing line.

Think of it like this: a histogram is like stacking LEGO blocks to show where data clusters. KDE is like spreading modeling clay over those blocks and smoothing it into a continuous hill—you see the same overall shape, but without the sharp edges.

Why Use Density Plots?

Density plots reveal subtle patterns that histograms might hide, especially with small datasets or when bin choices create misleading shapes. They're perfect for:

  • Comparing multiple distributions (overlay several smooth curves)
  • Identifying modes (peaks) in the distribution
  • Spotting skewness and tail behavior
  • Creating publication-quality visuals

How It Works

KDE places a small probability distribution (usually a Gaussian curve) at each data point, controlled by a bandwidth parameter. Narrow bandwidth = bumpy, detailed curve. Wide bandwidth = smoother, more generalized curve. Finding the right bandwidth is key—too narrow overfits to noise, too wide loses important features.

When to Use

During univariate analysis, create density plots after examining histograms and box plots. They complement these tools by showing distribution shape with precision, helping you understand whether your data is unimodal, bimodal, symmetric, or skewed.

Key Takeaway: Density plots use Kernel Density Estimation to transform discrete data points into smooth, continuous distribution curves that reveal patterns more elegantly than histograms—especially useful for comparing distributions and spotting subtle shapes.