[R] normalised Voigt random numbers

Ben Bolker bolker at ufl.edu
Tue Nov 27 22:57:01 CET 2007




Waterman, DG (David) wrote:
> 
> Dear list,
> 
> I would like to generate random numbers from a Voigt distribution,
> hopefully in a way as simple as getting random numbers from a normal
> distribution with 'rnorm'. Is there any package to do this? Speed is an
> issue in this application. Or, as the Voigt distribution is a
> convolution of a Gaussian and a Lorentzian, can I simply combine random
> numbers from rnorm and rcauchy in some way (I'm not sure about the maths
> of this)?
> 
> 

  I spent a while with the wikipedia entry on the Voigt distribution, which
gives
an expression for the pdf that I don't understand ... but the answer to your
question appears very simple.

rvoight <- function(n,sigma,gamma) {
   rnorm(n,sd=sigma)+rcauchy(n,scale=1/gamma)
}

 at least according to the formulas on the wikipedia page.

  Ben Bolker

-- 
View this message in context: http://www.nabble.com/normalised-Voigt-random-numbers-tf4849610.html#a13886025
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list