Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1993
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1993

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

Search the Archive

Re: random numbers from user-defined distributions

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: random numbers from user-defined distributions
  • From: jacobson at cello.hpl.hp.com
  • Date: Thu, 07 Jan 93 08:31:32 -0800

Dr. Robert B. Nachbar asks 

   does anyone know how to use Random with an arbitrary distribution
   function? i would like to generate random numbers in the range {0, Pi}
   with a probability distribution function (PDF) of Sin[x].

The standard technique is to take the inverse cumulative distribution
function and apply it to a random number in the range 0-1.

So in your case the cumulative distribution is given by

In[4]:= Integrate[Sin[xx],{xx,0,x}]/Integrate[Sin[xx],{xx,0,Pi}]

        1 - Cos[x]
Out[4]= ----------
            2

So your function is ArcCos[1-2 Random[]], or alternatively, 
ArcCos[Random[Real,{-1,1}]]

  -- David Jacobson










  • Prev by Date: Problem with Plot Ticks
  • Next by Date: Re: random numbers from user-defined distributions
  • Previous by thread: random numbers from user-defined distributions
  • Next by thread: Re: random numbers from user-defined distributions