Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: how to get random numbers from a distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81487] Re: how to get random numbers from a distribution
  • From: "Nasser Abbasi" <nma at 12000.org>
  • Date: Wed, 26 Sep 2007 06:30:29 -0400 (EDT)
  • References: <fd7s2q$cfd$1@smc.vnet.net>

<tdoxmail at gmail.com> wrote in message news:fd7s2q$cfd$1 at smc.vnet.net...
> 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:

http://12000.org/my_notes/generate_random_variables/index.htm

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.

http://12000.org/tmp/091907_502/part32.htm

Nasser






  • 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