h = c(1, 2, 3);
z = c(4, 5, 6);
## Devroye-like method -- only use if h contains integers, preferably small integers.
X = rpg.devroye(100, h, z);
h = c(1.2, 2.3, 3.2);
z = c(4, 5, 6);
## Sum of gammas method -- this is slow.
X = rpg.gamma(100, h, z);
## Hybrid method -- automatically chooses best procedure.
X = rpg(100, h, z);
Run the code above in your browser using DataLab