[R] Loop

Val valkremk at gmail.com
Wed Mar 3 20:15:43 CET 2010


Hi all,

Assume the following function that generate a random number.

z1<-function (n, eta)
{
        wv <- runif(n)
        wz <- (-1/eta) * log(wv)
        wz
}
y <- z1(100,4)
mean(y)


I want to run this function  say  1000 times and I want to count if
the mean(y) outside the following range 0.20 to 0.30.

How do I do it in R?

Thanks in advance



More information about the R-help mailing list