Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have attached my problem questions with my code. My question is: Does the code for the quasi random and monte carlo methods look correct?

I have attached my problem questions with my code. My question is: Does the code for the quasi random and monte carlo methods look correct? If I changed the skip or leap sizes in the haltonset calculation then the quasi random results can change dramatically which makes me think something is wrong. I have attached the questions of the project but I want to see if my code is correct.

image text in transcribed

image text in transcribed

And here is the code I am using

%%Matlab code for Monte Carlo simulation for finding value of pi clear all close all

NN = [10^3 10^4 10^5]; %sets different evaluations to see the changes in the integration and difference values.

for ii=1:length(NN) N=NN(ii); %Reads the NN values for the evaluation ax =0;bx =2; %project gave integration from 0->2 ay =0;by =2; x = ax + (bx-ax).*rand(N,1); y = ay + (by-ay).*rand(N,1); hits=0; for i=1:N if y(i)

for ii=1:length(NN) N=NN(ii); %Reads the NN values for the evaluation ax =0;bx =2; %project gave integration from 0->2 ay =0;by =2;

p = haltonset(2,'Skip',100,'Leap',68); p = scramble(p,'RR2'); rar=net(p,N); rary=net(p,N); x = ax + (bx-ax).*rar; y = ay + (by-ay).*rary; hits=0; for i=1:N if y(i)

I think that my code is right best I can tell and if it is I was going to conclude that the psuedorandom generator of the Monte Carlo method is more accurate to the error function however the quasi random generator has a more consistent solution across the different size evaluation matrices.

Any help is greatly appreciated.

Problem 1 The error function erf is defined as 2 _+2 erf(x) = El e-t dt. 1. Give a probabilistic interpretation of erf. 2. Use Monte Carlo integration to evaluate erf(2). Discuss its convergence. Hint: you can take the value erf(2) from MATLAB as exact. 3. Generalize your code to d dimensional integration and consider the calculation of / 2 d 2 2 | .. exp(-t - ... - t) dt ... dtd. JO Given a budget of 100,000 function evaluations, what is the largest dimension d for which your routine gives a reasonable answer? Justify. Hint: the above expression is equal to (erf(2))d. Problem 3 1. Choose either the Halton or the Sobol sequence of quasi-random numbers. Briefly describe how they are constructed. 2. Illustrate graphically the difference between pseudo-random numbers and quasi-random numbers. 3. Repeat step 2 of Problem 1 with quasi-random numbers. Comment. Problem 1 The error function erf is defined as 2 _+2 erf(x) = El e-t dt. 1. Give a probabilistic interpretation of erf. 2. Use Monte Carlo integration to evaluate erf(2). Discuss its convergence. Hint: you can take the value erf(2) from MATLAB as exact. 3. Generalize your code to d dimensional integration and consider the calculation of / 2 d 2 2 | .. exp(-t - ... - t) dt ... dtd. JO Given a budget of 100,000 function evaluations, what is the largest dimension d for which your routine gives a reasonable answer? Justify. Hint: the above expression is equal to (erf(2))d. Problem 3 1. Choose either the Halton or the Sobol sequence of quasi-random numbers. Briefly describe how they are constructed. 2. Illustrate graphically the difference between pseudo-random numbers and quasi-random numbers. 3. Repeat step 2 of Problem 1 with quasi-random numbers. Comment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

Students also viewed these Databases questions

Question

=+21.6. Prove (21.9) by Fubini's theorem.

Answered: 1 week ago