Skip to content
Prev 256439 / 398506 Next

Help with basic loop

Hi,

I think you can do this without a loop (well, replicate() is based on 
sapply()):
prob<-numeric(1000)
task1 <- replicate(1000,runif(1, min=0.8, max= 0.9))
task2 <- replicate(1000,runif(1, min=0.75, max= 0.85))
task3 <- replicate(1000,runif(1, min=0.81, max= 0.89))
prob <- task1*task2*task3

It might not be faster, but I don't think it can be slower. And I find 
the code easier and clearer.
Please correct me if this is not equivalent.

HTH,
Ivan


Le 4/11/2011 01:06, Daniel Malter a ?crit :