Dimitris Rizopoulos wrote:
> maybe you're looking for something like this:
>
> x <- rpois(999, 2000)
> y <- numeric(length(x))
> for (i in seq_along(x))
>      y[i] <- sum(exp(rgamma(x[i], scale = 2, shape = 0.5)))
>
>   
Or use sapply,
sapply(x, function(x) sum(exp(rgamma(x[i], scale = 2, shape = 0.5)) )

or even

replicate(999, sum(exp(rgamma(rpois(1,2000), scale = 2, shape = 0.5)) )

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to