Skip to content

Simulating inhomogeneous Poisson process without loop

3 messages · Tristan Linke, Krishna Kumar, Harun Ozkan

#
A reproducible example would help, have you tried FOREACH



On Jul 3, 2011, at 7:53 AM, Tristan Linke <tristan.linke at gmail.com>  
wrote:
#
dt=.01;
t=seq(0, .5, by=dt)
apply(matrix(t),  1,  function (x)  { rbinom(1,1,prob=x  )} )

would produce a  series of Bernoulli trials with success probability t  
\in  [0, .5].
  In my humble opinion, this style is more pertinent in terms of the 
programming logic of R although I am not very sure about the efficiency.

All the best.
7/3/2011 7:09 PM, Krishna wrote: