RandomNumbers

Computer random number generators produce uniformly

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: computer and the numbers are generated while a computer program is running. Computer random number generators produce uniformly distributed numbers in the range [0, 1]. We will see below how to generate other distributions starting from the uniform. A ‘good’ random number generator has the following properties: • The numbers must have the correct distribution. Since most of the random number generators meant to produce a uniform distributions that means the distribution should be uniform. • The period of the sequence should be longer than the numbers necessary for the application. All random number generators will repeat the same sequence of numbers eventually, but it is important that the sequence is sufficiently long. • The sequence is uncorrelated. There are many tests that test the quality of the random number generator. • Visual inspection. A good test is to plot the consecutive sub series ri∈even , ri∈odd as a scatter plot. Figure 1 shows a good random number sequence where Figure 2 shows a sequence with repetition. iii • Moment tests. The moments of a uniform distribution √ 1N k 1 ri = xk P (x)dx + O(1/ N ) ≈ N i=1 k+1 The random sequence should converge to 1/(k + 1) as N → ∞. • Correlation test. Check the autocorrelation of the series. This should have no correlation above the noise for all lags. • The spectral test. The power spectrum of the series should be flat. • Diehard Battery of Tests of Randomness. http://stat.fsu.edu/pub/diehard/ • My favorite one. http://www.iro.umontreal.ca/~simardr/testu01/tu01.html Figure 1: A good random number generator 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Inverse Transform Consider a change of variables r → x such as if r are uniformly distributed, u(r) = const, then the probability distribution w(x) is what we desire. For the probability to be conserved on the transformation dr u(r) u(r) dr = w(x) dx ⇒ w(x) = dx iv Figure 2: A bad random number generator 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 To find the mapping from x to r we calculate the cumulative distribution function (CDF) of both probability distributions, from 0 to r and -∞ to x respectively, and since that is not decreasing x r u(r )dr = r = 0 −∞ w(x) dx = F (x) After the integral of the targ...
View Full Document

Ask a homework question - tutors are online