title: Simulate Compound poisson process in r
body: <p>I'm trying to simulate a compound Poisson process in r. The process is defined by $ \sum_{j=1}^{N_t} Y_j $ where $Y_n$ is i.i.d sequence independent $N(0,1)$ values and $N_t$ is a Poisson process with parameter $1$. I'm trying to simulate this in r without luck. I have an algorithm to compute this as follows: 
  Simutale the cPp from 0 to T: </p>
  
  <p>Initiate: $ k = 0 $</p>
  
  <p>Repeat while $\sum_{i=1}^k T_i &lt; T$</p>
  
  <p>Set $k = k+1$</p>
  
  <p>Simulate $T_k \sim exp(\lambda)$ (in my case $\lambda = 1$)</p>
  
  <p>Simulate $Y_k \sim N(0,1)$ (This is just a special case, I would like to be able to change this to any distribution)</p>
  
  <p>The trajectory is given by $X_t = \sum_{j=1}^{N_t} Y_j $ where $N(t) = sup(k : \sum_{i=1}^k T_i \leq t )$</p>
  
  <p>Can someone help me to simulate this in r so that I can plot the process? I have tried, but can't get it done. </p>