Answer the following:

Question 1: What is the expected number of heads in tossing a coin three times?

#Let ev be the expected number of heads in this experiment. Since this is a binomial distribution where each trial is independent from the others, use the formula ev = n*p where n is the number of trials in the experiment while p is the probability of success of tossing heads for a single trial.

n = 3
p = 0.5

ev <- n*p
print(ev)
## [1] 1.5

Question 2: What is variance number of heads in tossing a coin thrice?

#The variance number v of heads in tossing a coin thrice can be solved using the formula v = (np)(1-p)

vn <- (n*p)*(1-p)
print(vn)
## [1] 0.75

Question 3: You flip a fair coin 6 times, what is the probability of getting 5 or 6 heads?

c <- dbinom(5, 6, 0.5) + dbinom(6, 6, 0.5)
print(c)
## [1] 0.109375

Question 4: Suppose that diastolic blood pressures (DBPs) from men aged 30-44 are normally distributed with a mean of 80mmHg and a standard deviation of 10 mmHg. What is the probability that a random 30-44 year old has a DBP less than 70?

a <- pnorm(70, mean=80, sd=10)
print(a)
## [1] 0.1586553

Question 5: Brain volume for adult men is normally distributed with a mean of about 1,100 cc with a standard deviation of 80 cc. What brain volume represents the 95th percentile ?

b <- qnorm(0.95, mean = 1100, sd = 80)
print(b)
## [1] 1231.588

Question 6: Refer to Q6, Brain volume for adult men is normally distributed with a mean of about 1,100 cc with a standard deviation of 80 cc. Consider the sample mean of 100 random adult men from this population. What is th 95th percentile of the distribution of the sample mean?

#We know that taking a random sample of 100 adult men create different possible sample means. By Central Limit Theorem, the distribution of the sample means is also normally distributed with a mean of 1,100 cc and a standard deviation of 80/√100 = 8

d <- qnorm (0.95, mean= 1,100, sd = 8)
print(d)
## [1] 14.15883

Question 7: In a population of interest, a sample of 12 men yielded a sample average brain volume of 1,100cc and a standard deviation of 30cc. What is a 95% Student’s T confidence interval for the mean brain volume in this new population?

sm <- 1100
sd <- 30
n <- 12
quantile <- 0.975  #This means that 0.975 is 95% with 2.5% on both sides of the range

error <- qt(quantile,df=n-1)*sd/sqrt(n) 

lower_bound_of_the_interval <- sm-error
upper_bound_of_the_interval <- sm+error

print(upper_bound_of_the_interval)
## [1] 1119.061
print(lower_bound_of_the_interval)
## [1] 1080.939