Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Converting this program from Octave to R: Hi, can anyone who knows Octave rewrite this exact code in R? I have never used Octave and
Converting this program from Octave to R:
Hi, can anyone who knows Octave rewrite this exact code in R? I have never used Octave and can't figure it out. Thanks
The following Octave program generates 10000 iid standard normal draws by rejection sampling from a standard Cauchy distribution. You should check the output array IN to confirm that the resulting values are actually normal rather than Cauchy The counter ii keeps track of the total number of Cauchy draws generated. I got a total of 15, 370 (it is a random variable hence your results may vary). Thus around 1.5 uniform draws must be generated for each normal value produced. The Box-Muller method generates one normal draw per uniform draw, so is more efficient. 11 =0; for it-1:10000 while (1) Z = tan (pi*rand (1,1)); R - exp(-Z 2/2) (1+Z2)*sqrt (e)/2; if (rand(1,1) R) break; endif endwhile endforStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started