A.
Code:
> friends=read.table(file="facebookfriends.txt",header=T)
> friends
> m=mean(friends[,1])
> std=sd(friends[,1])
> hist(friends[,1], freq = FALSE)
> m=mean(friends[,1])
> std=sd(friends[,1])
> curve(dnorm(x, mean=m, sd=std), col="blue", lwd=2, add=TRUE)
> lines(density(friends[,1]),col = "red", lwd=2)
> t.test(friends[,1], conf.level=0.95, mu = 130, alternative = "two.sided")
1.
They are normally distributed.
The density curve looks approximately bell-shaped and symmetric. We could say that it is close to normal distribution.
2.
It is appropriate to use the t-test because the distribution is normal even it is not perfectly normally distributed.
3.
Mean = 119.0667
Standard deviation = 29.56691
Standard Error = 29.56691/sqrt(30) =5.3981545 t* = t(df = 29, CL = 95%) = 2.045
Margin of Error = t*(Sd Error) = 11.0392
Confidence Interval = (119.0667-11.0392, 119.0667+11.0392) = (108.0275, 130.1059)
4. One Sample t-test data: friends[, 1] t = -2.0254, df = 29, p-value = 0.05212 alternative hypothesis: true mean is not equal to 130
95 percent confidence interval: 108.0262 130.1071 sample estimates: mean of x 119.0667
Confidence Interval = (108.0262, 130.1071)
The confidence interval obtained by the software is close to the one obtained by hand.
5.
We are 95% confident that the average number of friends on facebook for students in this large university would fall in the interval (108.0262, 130.1071.)
B.
> counts=read.table(file="pickcount.txt",header=T)
> counts
> hist(counts[,1], freq = FALSE)
> m=mean(counts[,1])
> std=sd(counts[,1])
> curve(dnorm(x, mean=m, sd=std), col="blue", lwd=2, add=TRUE)
> lines(density(counts[,1]),col = "red", lwd=2)
> boxplot(counts$PickCount)
> points(m,pch=18)
> qqnorm(counts[,1],main="Normal Quantile