Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Different PRNGs in Matlab The latest version of Matlab has many different methods for creating pseudo-random uniform (0, 1) sequences. You can create multiple sequences

image text in transcribedimage text in transcribed

Different PRNGs in Matlab The latest version of Matlab has many different methods for creating pseudo-random uniform (0, 1) sequences. You can create multiple sequences (often called "streams") using different seeds or different methods and compare them. Here's how to create 3 different streams using 3 different methods. methodlRandStream (mcg16807') method2RandSt ream(swb2712') method3-RandStream ('mt 19937ar Method 1 was Matlab's default before 1995. It is a LCG with m 231 - 1 and a -75. It is too simple for modern applications. Method 2 was Matlab's default from 1995 to 2006. It is not a LCG and it is awful. I once spent many hours debugging before I realized that the problem was with this PRNG. Method 3 is the Mersenne Twister, which is currently a very popular PRNG and which is Matlab's default since 2007. Assuming you have a recent version of Matlab, then if you just use rand in Matlab, then you will get method 3 without having to specify anything. To generate an r c array of pseudo-random numbers using one of these streams and store it in the matrix U, type U-rand (method?, r,c); where you replace the ? with one of the numbers 1,2, or 3 to get the desired method. [On later homework sets, when we are finished exploring PRNGs and just want the best PRNG, you can use U-rand (r, c); without specifying a method. This uses the default method 3, in this case_which seems to be the best of Matlab's choices.] Demo Convince yourself that the PRNGs are deterministic. For example, create two copies of method 3, say method3a = Randstream ( ,mt 1 9937ar'); and method3b RandStream('mt 1 9 937ar' ); Now rand (method3a) and rand (method3b) should behave identically. Call them repeatedly to verify. Four different PRNGs A. The LCG that you created in problem 1 [after converting to (0, 1) by dividing each Rn by m] B. Matlab method 1 above. C. Matlab method 2 above. D. Matlab method 3 above. Higher dimensional uniformity If we group a pseudo-random sequence U1, U2, , Und into disjoint blocks of length d, say, (Ui, , Ud), U+ , U2d),.. . , (U(n-1)d+1,.. , Und) then the d-dimensional blocks should be uniformly distributed over the d-dimensional unit cube (0,1)d. It is very challenging to engineer a PRNG that remains uniform in high dimensions (large d). The Mersenne Twister is supposedly uniform up to about 600 dimensions. 4. Consider the following subset of the 30-dimensional unit cube: What is P((, , V30) E)? Notice that the event Suppose Vi, (V, ,V30) E E is just the event that Vi

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions