Skip to content
Prev 276759 / 398506 Next

Sampling with conditions

Dan
Nordlund, Dan (DSHS/RDA) wrote:
Perhaps a little bit of context may be helpful, 
I am trying to figure out the ideal age structure for a population of ten
individuals that would yield the best overall survival rate given that each
age group has different survivorbility and different reproductive rates. 
So yes, having a bias for smaller numbers would be a problem. The only other
problem that I see with your revised code is that there will be a bias
towards having higher numbers in the first age group or first row of the
column...
The other idea I was playing with was to create a series of ifelse
statements for each row of the column...
Something like:
n<-matrix(0,nr=5,ncol=10)
n[1,1]<-sample(0:10,1)
n[2,1]<-ifelse(n[1,1]=10,0,sample(0:10,1))
n[3,1]<-ifelse(sum(n[i,1])>10,0,sample(0:10,1))
etc...
I still think that might be biased towards high numbers in the first rows
though...
hmmm
SJ



--
View this message in context: http://r.789695.n4.nabble.com/Sampling-with-conditions-tp4014036p4017351.html
Sent from the R help mailing list archive at Nabble.com.