Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: rician random number

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15211] Re: rician random number
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 22 Dec 1998 04:01:41 -0500
  • Organization: University of Western Australia
  • References: <754u82$jdh@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Tomas Garza wrote:

> I suggest you use an approximate method based on an idea by Paul Abbott:

Two possible improvements to this idea. 

[1] For the PDF

In[1]:= PDF[A_, s_][r_] = (r/s^2*BesselI[0, (r*A)/s^2])/E^((A^2 +
r^2)/(2*s^2)); 

use NDSolve (and dynamic programming) instead of NIntegrate to determine
the CDF:

In[2]:= CDF[A_, s_] := CDF[A, s] = Module[{y}, 
    First[y /. NDSolve[{y'[r] == PDF[A, s][r], y[0] == 0}, y, {r, 0,
10}]]]

[2] From the plot, 

In[3]:= cdfplot = Plot[CDF[1, 1][x], {x, 0, 10}, PlotRange -> All]; 

extract the plotpoints (which takes advantage of the adaptive code built
into Plot):

In[4]:= pts = Cases[cdfplot, Line[{x__}] -> x, Infinity]; 

and then numerically compute the inverse function using interpolation:

In[5]:= inverseCDF[1,1] = Interpolation[Reverse /@ pts]

In[6]:= Table[inverseCDF[1,1][Random[]], {10}]

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at physics.uwa.edu.au  AUSTRALIA                       
http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: strange function that defines a function---how do I do it?
  • Next by Date: Re: button to read in an external file
  • Previous by thread: Re: Re: rician random number
  • Next by thread: NDSolve