Line 50: Line 50:
 
[[References:]]
 
[[References:]]
  
Martin Haugh, " Generating Random Variables and Stochastic Process", 2004
+
Martin Haugh, 2004, " Generating Random Variables and Stochastic Process"
[http://www.columbia.edu/~mh2078/MCS04/MCS_generate_rv.pdf]
+
Retrieved from [http://www.columbia.edu/~mh2078/MCS04/MCS_generate_rv.pdf]
  
MathWorks
+
Ozgur KARAYALCIN, 2007, "Generating Random numbers and Random variables",
[http://www.mathworks.com/index.html]
+
Retrieved from [http://www.mathematik.uni-kl.de/~seifried/eng/teaching/teach_07ws/ozgur.pdf]
  
Ozgur KARAYALCIN, "Generating Random numbers and Random variables", 2007
+
MathWorks Reference
[http://www.mathematik.uni-kl.de/~seifried/eng/teaching/teach_07ws/ozgur.pdf]
+
Retrieved from [http://www.mathworks.com/index.html]

Revision as of 15:34, 15 April 2013

1. Generating uniformly distributed random numbers between 0 and 1: U(0,1)

a) Linear Congruential Generators

A linear congruential generator has the property that numbers are generated according to

Zi = (aZ(i-1) + c) mod m

where m, a, c and Z0 are non-negative integers. We say that m is the modulus and that Z0 is the seed. The sequence that we obtain clearly satisfies 0<= Zi < m. In order to generate pseudo-random numbers, U1,...,Un,..., we set Ui = Zi/m. Note that Ui is inside(0,1) for each i.

We now act as though the Ui's constitute an independent sequence of U(0,1) random variables.


b) Using MATLAB Functions

rand(n)

r = rand(n) returns an n-by-n matrix containing pseudorandom values drawn from the standard uniform distribution on the open interval (0,1). r = rand(m,n) or r = rand([m,n]) returns an m-by-n matrix.

Example: rand(1, 5)

ans = 0.8147 0.9058 0.127 0.9134 0.6324



2. Generating Normal Random variables

a) Box-Muler method

If Z- N(0, I2) then

R=(Z1)^2 + (Z2)^2 is exponentially distributed with mean 2.

Given R, the point(Z1, Z2) is uniformly distributed on the circle of radius sqrt(R) centered at the origin.

Generate R and choose a point uniformly from the circle of radius sqrt(R). (r = -2log(U1))

To generate a random point on a circle, generate a random angle uniformly between 0 and 2pi and map the angle to a point on the circle.

The random angle can be generated as V=2*pi*U2 and the corresponding point has coordinates (sqrt(R)*cos(V)), (sqrt(R)*sin(V)).

b) Using MATLAB Functions

normrnd(mu, sigma)

r=normrnd(mu, sigma) generates random numbers from the normal distribution with mean parameter mu and standard deviation parameter sigma. mu and sigma can be vectors, matrices, or multidimensional arrays that have the same size, which is also the size of R. A scalar input for mu or sigma is expanded to a constant array with the same dimensions as the other input.


References:

Martin Haugh, 2004, " Generating Random Variables and Stochastic Process" Retrieved from [1]

Ozgur KARAYALCIN, 2007, "Generating Random numbers and Random variables", Retrieved from [2]

MathWorks Reference Retrieved from [3]

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn