1

This previous SO question regards converting a Uniform distribution to a Normal distribution.

For Monte-Carlo simulations, I have a need not only for Normal (Gaussian), but for some computationally efficient ways to generate large numbers of samples from "fat-tailed" or heavy-tailed distributions, using a given (64-bit or double) uniform RNG as input. Examples of these distributions include: Log-normal, Pareto, Student-T, and Cauchy.

Use of inverse CDFs is acceptable given computationally efficient means of computing the inverse CDF as needed.

The tag is for a language-independant algorithms, but the implementations needed are for basic procedural programming languages (C, Basic, procedural Swift, Python, et.al.)

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • 1
    [How to generate a Cauchy random variable](https://math.stackexchange.com/questions/484395/how-to-generate-a-cauchy-random-variable) – samgak Dec 29 '18 at 20:38
  • This is the subject of several books, and is therefore, I believe, the classic case of "too broad". Here is one of the books, by Christian Walck of Stockholm University [Handbook On Statistical Distributions for Experimentalists](http://staff.fysik.su.se/~walck/suf9601.pdf). – rici Dec 29 '18 at 23:25
  • I agree with @rici. [Here](http://www.nrbook.com/devroye/) and [here](http://www.eirene.de/Devroye.pdf) are links to a (quite large) text written by Luc Devroye back in 1986. It contains a multiplicity of algorithms to generate from a huge variety of distributions, take your pick. – pjs Dec 30 '18 at 16:14
  • Excellent sources. However I note that for the 4 distributions I asked about, these texts describe reasonable algorithms that would easily fit in a stackoverflow answer box. – hotpaw2 Dec 30 '18 at 16:39
  • 1
    @hotpaw2: if you had asked about one distribution, fine. But you said, "Examples include... et al", which requires a much more extensive response. – rici Dec 30 '18 at 16:48
  • @pjs: thanks. I was looking for those links but I got distracted. – rici Dec 30 '18 at 16:49

1 Answers1

1

A Cauchy random number can be expressed as:

scale * tan(pi * (RNDU01OneExc()-0.5)) + mu

Where RNDU01OneExc() is a random number in [0, 1), and mu and scale are the offset and scale, respectively.

A logarithmic normal random number can be expressed as exp(Normal(mu, sigma)), where Normal(mu, sigma) is a normally distributed random number with mean mu and standard deviation sigma.

These and other kinds of distributions are mentioned in my article on random number generation and sampling.

Peter O.
  • 32,158
  • 14
  • 82
  • 96