PapaSwankey
PapaSwankey

Reputation: 55

Overlaying a normal pdf onto a histogram in R

I've looked through similar problems and I am unable to resolve mine based on what has been answered with them. I have a histogram of Body Mass Index Data. I have found the mean and sd of the data, and I am trying to overlay a normal pdf with the same mean and sd of the data to compare it with the histogram.

Here is what I have so far.

I used hist(BMI) to graph the histogram. I found the mean(BMI) to be 26.65 and the sd(BMI) to be 3.47.

I am trying to use the curve function to plot a normal curve with those same parameters over the histogram.

curve(dnorm(x, mean = 26.65, sd = 3.47), add = T, col = "red")

HistOverlay

As you can see, the red curve is barely visible at the very bottom of the histogram. Why is this error occurring?

Thank you.

Upvotes: 0

Views: 2311

Answers (1)

CAFEBABE
CAFEBABE

Reputation: 4101

The normal distribution is probability density function. Hence the integral of the function is 1. Simply speaking, it is the probability that a single individual has this BMI. To generate the result you want to have you need to multiply the curve with the size of your population.

Something along the line: curve(100*dnorm(x, mean = 26.65, sd = 3.47), add = T, col = "red")

Upvotes: 1

Related Questions