Math 472 Homework 3 - Math 472 Section 002 Professor Joseph...

This preview shows page 1 - 7 out of 13 pages.

Math 472 Section 002 Professor Joseph Conlon Homework 3 10/14/2016 Problem 1 A.) Y = - 2 for 0 X < 1/6, 2 for 1/6 X < 4/6, 3 for 4/6 X <1
B.) %Function: mat, 10/14/16, Math 472 %Takes input matrix has entries drawn from i.i.d. Uniform variables on (0, 1) and produces output from i.i.d. variables with the distribution of Y in part A function x=mat(m) a=size(m, 1); b=size(m, 2); N=a*b; for j=1:N if m(j)<=(1/6) m(j)=-2; elseif (m(j)>(1/6) && m(j)<=(4/6)) m(j)=2; elseif (m(j)>(4/6) && m(j)<=1) m(j)=3; end x=m; end command window: >> mat(rand(6,7)) ans = 2 -2 3 3 3 2 -2 -2 3 2 3 3 2 3 -2 -2 2 -2 2 -2 2 -2 2 3 3 2 2 3 3 2 2 2 3 -2 3 -2 2 -2 3 3 3 3 Problem 2 %Function: st, 10/14/16, Math 472
%Creates histograms for the distribution of S(T) for a different number of simulations function S=st(N) X=randn(1, N); S=(28*exp((.04-(.25^(2)/2))*.5-.04*(sqrt(.5))*X(:))); end using subplot >> subplot(1,3,1);hist(st(10^4),800);title('N=10^4') subplot(1,3,2);hist(st(10^5),1000);title('N=10^5') subplot(1,3,3);hist(st(10^6),1000);title('N=10^6') command window: >>hist(st(10^4, 800)
>>hist(st(10^5), 1000) >>hist(st(10^6), 1000)
Problem 3 %Function: MC, 10/14/2016, Math 472
%Runs Monte Carlo method to estimate value of option

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture