[R] Generate random sample interval

David Winsemius dwinsemius at comcast.net
Mon Aug 24 09:11:55 CEST 2009


On Aug 24, 2009, at 2:55 AM, Tammy Ma wrote:

>
> Hi, R users,
>
> I have a problem about how to generate random sample interval from a  
> duration.
>
> For example, during a time duration 0-70s, I want to generate a  
> sample which last 10s.
> the sample could be 0-10 or 30-40s or 25-35s etc
> How could I do it in R`??

?runif

Wouldn't you just generate a runif variable for the starting time that  
was in the range of 0-60 and then add 10 to each such start time? If  
the problem is any more difficult, then you will need to be more  
precise.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list