Simulating central limit theorem
The cental limit theorem (CLT) implies that we can apply statistical methods that work for normal distributions to problems involving other types of distributions. Interviewers are eager to check your understanding of CLT, especially if your future position involves A/B testing.
You will show the mechanics behind CLT on the example of die rolls.
In the last exercise, you generated 1000 die rolls by setting the size parameter: sample(1:6, size = 1000, replace = TRUE).
In step 1 of this exercise, you will generate 1 die roll output in a loop with 1000 iterations which is equivalent to the above.
To visualize:
- discrete data - you can use
barplot(table(x)), - continuous data - you can use
hist(x).
The die_outputs and mean_die_outputs vectors have already been initialized.
本练习是课程的一部分
Practicing Statistics Interview Questions in R
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Simulate 1000 die roll outputs
for (i in 1:1000) {
die_outputs[i] <- ___(___, size = ___)
}
# Visualize the number of occurrences of each result
___(table(___))