MathGroup Archive 2007

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

Search the Archive

Re: how to get random numbers from a distribution

<tdoxmail at> wrote in message news:fd7s2q$cfd$1 at
> Hi ya alll
> I am a new Mathematica user.
> I have a function that i use to generate a probability distribution
> (eg x^2). I want a random number generator, that should generate
> values from this probability distribution only,
> I know this Random function in mathematica, that can generate in
> particular range, but how do i tell to generate from a particular
> distribution.
> I created a list of values using my probability function but not able
> to integrate it with Random function so that random numnber takes
> value from that  list.
> Also I googled and saw some function like RandomChoice and some other
> but they are available in Mathematica6 and i use 5.2.
> Can u help with this.
> Thanks in advace

Mathematica can generate random numbers from known distributions. I have 
small note on this:

But If your density function, call it f(x),  is not one of the known ones to 
Mathematica, or if it one in which the inverse CDF of it is hard to find, 
then you can use the counting method called accept-reject method to generate 
random numbers from your specific distribution f(x). You would need to have 
an explicit form for f(x).

You would only need to use RandomReal[] and another known distribution (the 
envelope over your f(x)) to do that.

For example, I just wrote a Manipulate program to generate random numbers 
from normal distribution using the accept reject method, using as envelop 
the double exponential density. This is just to show how the accept-reject 
method work.


  • Prev by Date: Re: LegendreP error (bug?) in Mathematica
  • Next by Date: XML data structure parsing in Mathematica 6 using patterns
  • Previous by thread: Re: how to get random numbers from a distribution
  • Next by thread: Nullcline and getting "2" values for y