[R] [FORGED] Generate arrival of time based on uniform random number

Rolf Turner r.turner at auckland.ac.nz
Thu Feb 4 05:17:12 CET 2016


This looks very much like a homework problem and this list has a "no 
homework" policy.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

On 04/02/16 17:08, smart hendsome via R-help wrote:
> Hi everyone,
> I have problem regarding to generate arrival of time based on uniform random number.
> Let day0 = 0.383, lambda = 0.2612
>
> 1) Generate uniform random number (already settled) using the code below:
> set.seed(1234)
> rand.no <- function(n,itr){
>    matrix(runif(n*itr, 0, 1), nrow=n, ncol=itr)
> }
> x<-rand.no(10,1)
> 2) For day 1,
>     a) if 1st rand.no < day0, then its not rain,  else its rain (i want the rseult in next colum, let say rain)
> 3) For day 2 and so on ( it depend from next rain when it happened)
> 4) Next rain,
>     to know the next rain i need i need to calculate using the exponential
>
>    a) 1st rain = - ln (1st rand.no) / lambda
>    b) 2nd nextRain = 1st rain - ln (2nd rand.no) / lambda
>    c) 3rd nextRain = 2nd next rain - ln (3rd rand.no)/lambda,  and so on
>   eg: if nextRain = 2.435, then 2nd day will rain
>
>
> Hope anyone can help me solve this problems. Thanks so much.



More information about the R-help mailing list