Site menu:




Generating random numbers from a distribution specified by its Laplace transform

This page provides R programs related to [Ref 1], which describes a method of simulating random variables from an absolutely continuous distribution that is specified only by its Laplace transform. Random numbers are generated using the inversion method, with the cumulative distribution function obtained by numerical inversion of the Laplace transform [Ref 2]. The code should work on R 2.6.1 onwards.

To use the programs, download them into a single directory and make sure this is accessible from R. Then you can run the programs from within R using the source function, for example

> source("table1.r")

You can download the files as a single WinZip file, or individually by clicking on the links below.

The function for generating random numbers is in the file rlaptrans.r. The file rdevroye.r provides a function that implements an alternative method described in [Ref 3], which is applicable less generally. To use these functions you need to supply a function to calculate the Laplace transform. To see how this works, look at the file gammaeg.r, which shows how these functions can be used to generate gamma random variables.

The programs table1.r and table3.r generate Tables 1 and 3 in [Ref 1]. They may take a few minutes to run. They use slightly modified versions of the random number generators that count the number of transform inversions used. These modified versions are rlaptranscount.r and rdevroyecount.r

The programs figure1.r and figure2.r generate Figures 1 and 2 in [Ref 1]. Figure 1 uses an additional function invlt.r Finally, the program copulaeg2.r gives an additional example of a nested Archimedean copula that is described in [Ref 2], based on the algorithm described in [Ref 4].

[Ref 5] also discusses the use of numerical Laplace transform inversion to sample from Archimedean copulas.


References

[1] Ridout, M.S. (2009) Generating random numbers from a distribution specified by its Laplace transform. Statistics and Computing, 19, 439-450. [Journallink]

[2] Abate, J. and Choudhury, G.L. and Whitt, W. (2000). An introduction to numerical transform inversion and its application to probability models, In Computational Probability, W. Grassmann (ed), pp. 257-323, Boston: Kluwer.

[3] Devroye, L. (1981). On the computer generation of random variables with a given characteristic function, Computers and Mathematics with Applications, 7, 547-552.

[4] McNeil, A.J. (2008). Sampling nested Archimedean copulas. Journal of Statistical Computation and Simulation, 78, 567-581. [Preprint]

[5] Hofert, M. (2007) Sampling Archimedean copulas. Computational Statistics and Data Analysis, 52, 5163-5174.