Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Random Number Generators
Replies: 1   Last Post: Dec 31, 1997 8:34 AM

 Messages: [ Previous | Next ]
 Manish Posts: 2 Registered: 12/7/04
Random Number Generators
Posted: Dec 31, 1997 7:36 AM

Deal all,

I have a query regarding the nature of rand() and randn() functions on
Matlab, a software I'm just starting out with.
How are the random number generators implemented? rand() on many computer
languages is a linear congruence generator with (of course) a finite
period. The period is dependent on an intelligent choice of constants (a,
b, c in the case shown below)

Typically, the linear congruence generator is

rand_no = ( a * prev_rand_no + b ) mod c
prev_rand_no = rand_no;

Obviously, c is the greatest random number possible.
To generate numbers between 0 and 1, the random number must then be
divided by (Rand_Max +1). For a good random generator, c = Rand_Max.

randn() may be implemented by transforming the uniform deviates generated
by rand() to normal random variables. The Box - Muller method is a
popular method.
How does Matlab go about generating its random numbers? What is the
period of rand()? I have to perform a simulation where the random number
generator is invoked lots of times, so these questions are critical to the
validity of my results.

Cheers!
Manish.

------------------------------------------------------------------------------
Electrical Engineering IV Singapore 297875.
National University of Singapore. Tel: 65 - 352 4574
------------------------------------------------------------------------------

Drink wet cement and get really stoned.

Date Subject Author
12/31/97 Manish
12/31/97 Christopher Lawton