Skip to content

Bound density estimates to valid domains

wrongdistributionsmechanicalWilke 2019 p. 64

Where does the tip distribution start and peak?

Plotly Express Tips dataset, 244 restaurant tip amounts in USD.

“Kernel density estimates have a tendency to produce the appearance of data where none exists, such as negative ages or prices”

Claus O. Wilke, "Fundamentals of Data Visualization", p. 63.

Also covered in Wilke 2019 (7 Visualizing Distributions: Histograms and Density Plots, p. 64).

CVD preview

Before

An unbounded Gaussian kernel leaks probability density down to -2.50 USD even though restaurant tips cannot be negative.

Download before Python code

After

Reflecting the kernel at zero keeps the density inside the valid non-negative range and preserves total area.

Download after Python code

Values

Tips range from 1.00 USD to 10.00 USD with a 2.90 USD median.

Tips start at 1.00 USD, peak near 2.00 to 3.00 USD, and taper smoothly to 10.00 USD.

Values used in both charts
MetricValue (USD)
Minimum tip1
Median tip2.9
90th percentile tip5
Maximum tip10