Hi,
How can I fill in the correct form the area?
Thanks
f <- dnorm(x, Mean, Sd) # Density function
qnorm(0.5, mean = 0, sd = 1) # 0
x <- pnorm(-1.5, mean = 0, sd = 1) # 0.0668072
qnorm(x, mean = 0, sd = 1) # -1.5
Mean <- 0
Sd <- 1
# Area:
lb <- -3 # Lower bound
ub <- -1.5
x <- seq(-3, 3, length = 100) * Sd + Mean
x2 <- seq(min(x), ub, length = 0.2) # New Grid
y <- dnorm(x2, Mean, Sd) # Density
# Plot Area:
plot(x, f, type = "l", lwd = 2, col = "blue", ylab = "", xlab = "Weight", main = "")
polygon(c(lb, x2, ub), c(0, y, 0), col = rgb(0, 0, 1, alpha = 0.5))
With that code, I obtain this:
How to fix it correctly?