# Calculating percentage that's equal to a value

Let's say I have a normal distribution with people lengths in which the mean is 170 cm and the standard deviation is 6 cm.

I know you can calculate the lower tail and higher tail of 180 cm with

pnorm(180, mean=170.6, sd=6.75, lower.tail=TRUE/FALSE)


But how would I get the percentage of the people that are equal to 180 cm?

And if I would like to get the percentage of people between 170 and 180 do I just do that with 175 cm?

Sorry I'm new to this and I just can't figure it out.

Since the normal distribution is a continuous distribution, the probability of any value is zero. Thus, the probability to obtain the value 180 is infinitely small, $p(X = 180) = 0\,$.

To calculate the probability of values between 170 and 180 you have to use the cumulative distribution function of the normal distribution, $\Phi\,$. This can be done with the R function pnorm. To obtain $p(170 < X < 180)$ you have to calculate the $p(X < 180)$ and subtract $p(X < 170)\,$.

# probability for X < 180
p_180 <- pnorm(180, 170.6, 6.75)
# probability für X < 170
p_170 <- pnorm(170, 170.6, 6.75)
# probability für 170 < X < 180
p_180 - p_170
# [1] 0.4535434


Hence, $p(170 < X < 180) \approx 0.45\,$.

### A visualization of the concept

You want to obtain the size of the red area (between 170 and 180). Since the full area under the curve is equal to one, the size of the area corresponds to the probability. First, you calculate the area between $-\infty$ and 180. Second, you subtract the size of the area between $-\infty$ and 170. The overlapping area is purple in the below figure.

The R code:

library(ggplot2)
ggplot(data.frame(x = c(150, 190)), aes(x = x)) +
stat_function(xlim = c(150, 180), fun = dnorm, args = list(mean = 170.6, sd = 6.75),
geom = "area", alpha = 0.5, fill = "red") +
stat_function(xlim = c(150, 170), fun = dnorm, args = list(mean = 170.6, sd = 6.75),
geom = "area", alpha = 0.5, fill = "blue") +
coord_cartesian(xlim = c(150, 190)) +
ylab("p")

• Thanks for the answers guys it makes good sense and I feel stupid for asking the exact 180cm question. – Sinan Samet May 27 '18 at 15:59

It is not possible to be exactly 180 cm in length - you are only as accurate as your measurement device, which always has some error. Mathematically, the probability of a normally distributed variable is the area under the curve, and there's no area under a single value.

There are many ways to find $P(170<X<180)$. One way is to find $P(X<180)$ and subtract $P(X<170)$.

You might find this question and answer valuable.

On the one hand, if you want to obtain the percentage of people with height between 170 and 180 you should use:

pnorm(180, mean=170.6, sd=6.75, lower.tail=TRUE/FALSE) -
pnorm(170, mean=170.6, sd=6.75, lower.tail=TRUE/FALSE)


The area you are considering is:

library(ggplot2)
# Obtained the code from
# http://rstudio-pubs-static.s3.amazonaws.com/58753_13e35d9c089d4f55b176057235778679.html
# Return dnorm(x) for 170 < x < 180, and NA for all other x
dnorm_limit <- function(x) {
y <- dnorm(x,mean=170.6,sd=6.75)
y[x < 170  |  x >180] <- NA
return(y)
}

# ggplot() with dummy data
p <- ggplot(data.frame(x=c(120,220)), aes(x=x))

p + stat_function(fun=dnorm_limit, geom="area", fill="blue", alpha=0.2) +
stat_function(fun=dnorm,args=list(mean=170.6,sd=6.75))


On the other hand, the probability of someone being exactly 180 is:

pnorm(180, mean=170.6, sd=6.75, lower.tail=TRUE/FALSE) -
pnorm(180, mean=170.6, sd=6.75, lower.tail=TRUE/FALSE)


The obtained probability is 0. This happens because the normal distribution is a continuous probability distribution.

Don't hesitate to ask if you have further doubts.