A compound poisson process is a stochastic process{Xt, t>=0} that can be represented as the random sum X(t)=sum Yi (ps i=1 to N(t)) t>=0, where {Nt,t>=0} is a poisson process and Y1,Y2...are iid independent of {Nt,t>=0}.
Algorithm:
step 1, set your parameters, e.g., i) lambda, ii) parameters of gamma distributions: shape-nu, scale-alpha.
step 2, set the sampling interval [0,T].
step 3, set the initial time t=0 and the initial value of x x=0.
step 4, generate Delta~Exponential(lambda).
step 5, obtain the jump time of Poisson process t=t+Delta