I have 100000 iid normal variables X1, . . . , X100000 from N(0,1) and for i ∈ {2, . . . , 100000} and want to plot the graph of the function \
$$ R_i = \frac{\max{X_j}}{\sqrt{2 \log i}} $$
where j=1,...,i. And Repeat the above experiment 10 times and plot the respective trajectories of Ri on the same graph. I tried this code
sample<- rnorm(100000,mean=0,sd=1)
i=2:100000
r=0
for (i in 2:100000){
for (j in 1:i){
r[i]=(max(sample[j]))/(sqrt(2*log(i)))
}
}
plot(r)
But the results are not logical. I think the for loop doesn't work properly in max(X_j) but I don't know where. Also how to repeat it 10 times, could you please help? Thank you!
This is more of a programming question as it is not quite about the law of the iterated logarithm.
R has a
cummaxfunction so you could do something liketo get something like