Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate Poisson process using R

I want to generate a process where in every step there is a realisation of a Poisson random variable, this realisation should be saved and then it should be realize the next Poisson random variable and add it to the sum of all realisations before. Furthermore there should be a chance that in every step this process stops. Hope that makes sense to you guys... Any thought is appreciated!

like image 760
user734124 Avatar asked Oct 20 '25 19:10

user734124


1 Answers

More compactly, pick a single geometrically distributed random number for the total number of steps achieved before stopping, then use cumsum to sum that many Poisson deviates:

stopping.prob <- 0.3  ## for example
lambda <- 3.5         ## for example
n <- rgeom(1,1-stopping.prob)+1  ## constant probability per step of stopping
cumsum(rpois(n,lambda))
like image 69
Ben Bolker Avatar answered Oct 23 '25 10:10

Ben Bolker