Re: [R] Setting max values for rpois

About this list Date view Thread view Subject view Author view Attachment view

From: Giovanni Petris (GPetris@uark.edu)
Date: Thu 13 May 2004 - 07:31:49 EST


Message-id: <200405122131.i4CLVnES006435@definetti.uark.edu>


Bret,

the following should do:

x <- sum(pmin(rpois(recruit.f, l),3))

Giovanni

> Date: Wed, 12 May 2004 16:11:08 -0500
> From: Bret Collier <bacolli@uark.edu>
> Sender: r-help-bounces@stat.math.ethz.ch
> Precedence: list
>
> R-users,
> I am simulating a birth process for 4 classes of individuals with
> l[i] being the average No. fetuses per individual. However, I need to
> bound the resulting values for each generated rpois to be <=3 (no
> individual can have > 3 offspring). I have not been able to figure out how
> to incorporate this into the below example. Any suggestions on integrating
> would be appreciated.
>
>
> recruit.f <- c(12, 12, 25, 51) #No. females in each age class
> l <- c(.05, 1.22, 1.6, 1.8) #mean No. fetuses for each age class
> x <- sapply(lapply(1:4, function(i) rpois(recruit.f[i], l[i])), sum)
>
> TIA,
>
> Bret A. Collier
> Arkansas Cooperative Fish and Wildlife Research Unit
> University of Arkansas
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

-- 

__________________________________________________ [ ] [ Giovanni Petris GPetris@uark.edu ] [ Department of Mathematical Sciences ] [ University of Arkansas - Fayetteville, AR 72701 ] [ Ph: (479) 575-6324, 575-8630 (fax) ] [ http://definetti.uark.edu/~gpetris/ ] [__________________________________________________]

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:09 EST