Let X be a random normal variable, with mean = 0 and standard deviation = 1
X = rnorm(10000, mean = 0, sd = 1)
Y is a normal variable, Y= 5X + 10
Y = 5*X + 10
Calculate mean and and standard deviation of Y
mean(Y)
## [1] 10.08981
sd(Y)
## [1] 5.011632
Visually examine whether Y follows a normal distribution
hist(Y)
qqnorm(Y)
First I set h (height) as a random normal variable with n = 10,000, and a mean of 51 and standard deviation of 3. Then, I use pnorm to calculate the area under the curve from 50. Since lower.tail is set to FALSE, it will calculate the area to the right of 50 on the curve (greater than 50).
h = rnorm(10000, 51, 3)
pnorm(50, mean = 51, sd = 3, lower.tail = FALSE)
## [1] 0.6305587
The probability is about .63, or 63%.
Probability that boy is taller than girl is the probability that (boy - girl) > 0. First I set boys and girls as random normal variables with the appropriate means and standard deviations. Then I create difference, which will be composed of the difference in boys and girls heights.
boys = rnorm(10000, 51, 3)
girls = rnorm(10000, 53, 2.5)
difference = boys - girls
Next, I will look for the probability of picking a positive number from difference by looking for the probability/area above 0. First I have to calculate the mean and standard deviation of difference.
mean(difference)
## [1] -2.045131
sd(difference)
## [1] 3.895124
pnorm(0, mean = -1.99, sd = 3.9, lower.tail = FALSE)
## [1] 0.3049359
If we choose boy and a girl at random, there is a 30.4% chance that the boy will be taller than the girl.