MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random number with custom distribution

  • To: mathgroup at
  • Subject: [mg107464] Re: Random number with custom distribution
  • From: Bill Rowe <readnews at>
  • Date: Sat, 13 Feb 2010 05:23:51 -0500 (EST)

On 2/12/10 at 5:08 AM, giurrero at (wiso) wrote:

>Dear experts, is there a simple way to generate a random sample of a
>custom distribution? With Random I can generate random numbers
>according to the predefined distribution (Uniform, Normal, ...) but
>what about custom distribution (in my case a polynomial function)?

You can generate pseudo random deviates from any distribution
you can define in Mathematica.

For x selected from any distribution, f, u = CDF[f,x] will have
an uniform distribution. So, if you can define the inverse CDF
function call it g, g[RandomReal[]] will have the desired distribution.

For example, values computed as


will have the same distribution as values computed as


If the inverse CDF function is not available in closed form or
expensive to compute, there are other methods to go from uniform
deviates to random deviates from another distribution. Probably
the reference to use would be Knuth, Seminumerical Algorithms
Vol 2. And if you are going to code your own random generator
you really really should read what Knuth has to say about random
number generation.

  • Prev by Date: Can I set Page Setup scale for a notebook programmatically?
  • Next by Date: Re: Covariant derivatives of tensors?
  • Previous by thread: Re: Random number with custom distribution
  • Next by thread: Re: Random number with custom distribution