Loop
Thank you Henrique, However, F1<-sum(!findInterval(colMeans(replicate(100, z1(100, 4))), 0.2:0.3)) F2<-sum(findInterval(colMeans(replicate(100, z1(100, 4))), 0.2:0.3)) the sum of the two (F1+F2) = number of replicates (in this case 100). Sometimes I do not get that sum. Do you know why? Val
On Wed, Mar 3, 2010 at 2:33 PM, Henrique Dallazuanna <wwwhsd at gmail.com> wrote:
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