I’m looking to run this for loop, but it takes an unacceptably long time (~20s) to execute. x and y are predefined vectors of length 2000000.
for(i in 1:2000000)
{
a <- runif(1)
b <- runif(1)
sqrtf <- sqrt(-log(b,10))
x[i] <- sqrtf*cos(a)
y[i] <- sqrtf*cos(b)
}
Any tricks available to speed this up a bit?
EDIT: fixed the sqrtf
1 Answer