# Import the babies data (in the import dataset box, we changed the delimiter from "comma" to "whitespace") library(readr) babies <- read_table2("babies.csv") # Plot the histogram of the mothers' ages (and notice one or two are apparently 99 years old...) # Really 99 is used to indicate the mother's age is unknown hist(babies$age, xlab = "Mothers' age") # To relace 99 with the median mothers' age: # Compute the median age and store it in the variable median_age median_age <- median(babies$age) # Replace any values of 99 in the age column with the median age. babies$age[babies$age == 99] <- median_age # Plot the age histogram one more time to check it looks more realistic hist(babies$age) # compute P(X <= 3) where X~N(2,5^2). # That is, where X has a normal distribution with mean 2 and variance 5^2. pnorm(q = 3, mean = 2, sd = 5) # compute P(X > 3) where X~N(2,5^2) 1 - pnorm(q = 3, mean = 2, sd = 5) # compute P(1 < X < 4) by computing P(X < 4) - P(X < 1), where X~N(2,5^2) pnorm(q = 4, mean = 2, sd= 5) - pnorm(q =1, mean =2, sd = 5) # try to approximate the blood pressure range in the example problem a = 7 pnorm(q = 120 + a, mean = 120, sd= 8) - pnorm(q = 120 -a, mean =120, sd =8) a = 6.9 pnorm(q = 120 + a, mean = 120, sd= 8) - pnorm(q = 120 -a, mean =120, sd =8) a = 6.5 pnorm(q = 120 + a, mean = 120, sd= 8) - pnorm(q = 120 -a, mean =120, sd =8) a = 6.7 pnorm(q = 120 + a, mean = 120, sd= 8) - pnorm(q = 120 -a, mean =120, sd =8)