Question: 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 endfor
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
