I have just started learning R and am studying some probability and statistics examples.
I have the following code snippet, which produces a vector x
of length 100000 and sample means of $\text{Unif}(−3, 3)$ with a random sample of size 100:
samplemean <- function() {
return(mean(runif(100, -3, 3))) }
x <- replicate(100000, samplemean())
I determined the sample average and sample variance of x
as follows:
(mean(x)) #sample mean
(var(x)) #sample variance
Let mux
and sig2x
be the expected value and variance, respectively, of a $\text{Unif}(−3,3)$ random variable. I'm trying to use the central limit theorem to calculate the probability that the sample average is less than 0.44, which is given by $P(Y < 0.44)$ where $Y$ is a $\text{N}(\text{`mux`}, \text{`sig2x`}/100)$ random variable.
I tried to use the function convolve
to achieve this, but this is my first time using it, so I really don't know what I'm doing here:
pX2fold <- convolve(x, rev(x), type = "o")
pX3fold <- convolve(pX2fold, rev(x), type = "o")
pX4fold <- convolve(pX3fold, rev(x), type = "o")
pX5fold <- convolve(pX4fold, rev(x), type = "o")
pX6fold <- convolve(pX5fold, rev(x), type = "o")
pX7fold <- convolve(pX6fold, rev(x), type = "o")
pX8fold <- convolve(pX7fold, rev(x), type = "o")
(pX8fold < 0.44)
Despite my best efforts, none of this seems correct.
I would greatly appreciate it if people could please take the time to explain my errors and show me how to do this.
?pnorm
). $\endgroup$