Question: you must use matlab or octave program. others are not allowed T.T. please use only above the two program to get solution. Problem 5: The

you must use matlab or octave program. others are not allowed T.T. please use only above the two program to get solution.
Problem 5: The Box-Muller Method (Ex. #2d, Chapter 10) (a) The Box-Muller transform (Box and Muller, 1958) is a pseudo-random number sampling method for generating pairs of independent N(0,1) random numbers, given a source of U(0,1) random numbers. It states that if U and U2 are independently distributed as U(0,1), their transformations e) sin (2mU2) R cost Rsinla 21og UI are independent RVs front N(0,1) It can be shown that if and Y are N(0,1) ly, then their polar coordinates R and e tan" (Y/X) are independent with R ~Exp(2) and e~U(0,2 Letting R VF2Tog ande 2mUn leads to the desired result (2). See Example 7b of Chapter 6 and #6.54 in p 274 (please read sing (2), write an Octave function BorMuller1(n) to implement the Box-Muller algorithm. It should have the following format: function BoxMuller1 (n) U-rand (n,2 U2-U(: ,2) (complete your octave code below) Generate 10,000 random sam ples from N(0,1) by using your BorMuller1 and make a histograan. (b) The Box-Muller algorithm is a nice way to generate normal RV However, in its basic form, it is often trapped into the problems of getting lag 0 and have increased computations because of sin and coe. The way to avoid these problems is to start the 8o-called hit-and-miss approach that is common in Monte Carlo methods. The idea is to generate uniform samples 00-1, 1) and Vi U(-1,1). instead of U(0,1, and choose only those which belong to the umit circle or its inside. This gives us a direct way of computing sin and cos by taking ratio and getting around the log 0. The algorithm for this modified Box-Muller method can be summarized as follows: step 1. Generate random mumbers Us and Un from U(0,1). step 2. Set Vi 201 1,Vi 20 -1, and S Vi VA. step 3. If S S 1, do step 4, otherwise, go back to step l. step 4. Return the independent unit normals: The following is a complete octave function code to implement the above procedure. function D) BoxMuller 2(n) 0: count 0: (a) while (count n) x(b) V1-2 rand (1,2 m)-1 V2-2 rand (1,2 n)-1 S-V1. 2 v 22. 2; %(c) indices find CSK 1) A(d) 8-5 (indices) i V1-V1(indicea): 20e) count-count length (indices) Xg) X-X(1:n) i 20h) Give your comments in (h) toexplain what is happening there. You have to show that you really understand these codes line by line. Then, generate 10,000 random samples by using BorMuller2 and make a histogram. Compare results with those from (a)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
