Foundation for Inference Part 2
Click here to open the slides (PDF).
Here’s the R code for the random number discussion.
sample(1:100, 1)
## [1] 72
sample(1:100, 1)
## [1] 54
set.seed(2112); sample(1:100, 1)
## [1] 6
random_numbers <- integer(1000)
for(i in 1:length(random_numbers)) {
set.seed(i)
random_numbers[i] <- sample(1:100, 1)
}
plot(1:length(random_numbers), random_numbers)
cor.test(1:length(random_numbers), random_numbers)
##
## Pearson's product-moment correlation
##
## data: 1:length(random_numbers) and random_numbers
## t = -0.11161, df = 998, p-value = 0.9112
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.06551171 0.05847292
## sample estimates:
## cor
## -0.003532972