liveBook · Manning

Probability density

As explained in Statistics Slam Dunk

A probability density function describes the relative likelihood density of a continuous random variable across its range.

A probability density function describes how concentrated continuous data are across their numeric range. In a density plot, the x-axis shows values while the y-axis shows density: higher density generally corresponds to more observations. section 4.5.1

Density plots help answer practical distribution questions:

  • Reveal the underlying shape of continuous data without choosing histogram bin counts. section 4.5.1
  • Highlight peaks or modes and make skewness or symmetry easier to assess. section 4.5.1
  • Support distribution checks, such as comparing a density plot with a Shapiro-Wilk normality test. section 5.5.1

NBA data distributions

Plot annual salary, projected win shares, or age for shortlisted free agents. Add vertical lines for the mean and median to see how typical values relate to the distribution. A separate deflections plot, paired with a Shapiro-Wilk p-value of 0.4235, is treated as consistent with a normal distribution. section 4.5.1 section 5.5.1

p1 <- ggplot(free_agents, aes(x = annual_salary)) +
 geom_density(alpha = .3, fill = "salmon") +
 geom_vline(aes(xintercept = mean(annual_salary, na.rm = TRUE)),
            color = "red", linetype = "longdash", size = .8) +
 geom_vline(aes(xintercept = median(annual_salary, na.rm = TRUE)),
            color = "blue", linetype = "longdash", size = .8) +
 labs(title = "Annual Salary Distribution",
      subtitle = "Shortlisted Free Agents",
      x = "Annual Salary", 
      y = "Density",
      caption = "Salary data is illustrative only") +
 scale_x_continuous(labels = comma) +
 theme(plot.title = element_text(face = "bold")) +
 annotate("text", x = 18000000, 
          y = .000000025, label = "Mean", color = "black",
          size = 4, fontface = "bold", angle = 90) +
 annotate("text", x = 14000000, 
          y = .000000025, label = "Median", color = "black",
          size = 4, fontface = "bold", angle = 90)

Use the ggplot2 example to draw a salary density curve, overlay mean and median lines, format the x-axis, and annotate the plot. section 4.5.1

How Statistics Slam Dunk covers it

How deep it goes
Explains axes, smoothing, interpretation, and plotting mechanics, without developing a formal probability derivation.
Examples
Uses salary, win shares, age, and deflections density plots, including mean and median overlays and a normality-test comparison.
What it assumes
Starts with continuous or numeric variables and demonstrates plotting through ggplot2 rather than assuming formal probability theory.
What you can do after
Build it via ggplot2, compare distributions, annotate mean and median, and evaluate approximate normality alongside a Shapiro-Wilk test.
How it connects
Connects probability density with histograms, boxplots, mean, median, skewness, symmetry, normal distribution, and Shapiro-Wilk testing.

Also explained in

Compare how 6 books explain probability density →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.