[R] Loop

Henrique Dallazuanna wwwhsd at gmail.com
Wed Mar 3 20:33:03 CET 2010


Try this:

sum(!findInterval(colMeans(replicate(1000, z1(100, 4))), 0.2:0.3))

On Wed, Mar 3, 2010 at 4:15 PM, Val <valkremk at gmail.com> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list