Question: Put a simulation loop around your code to simulate several one - year periods. Use at least 1 0 0 0 simulations, and generate a

Put a simulation loop around your code to simulate several one - year periods. Use at least 1 0 0 0 simulations, and generate a histogram showing the distribution of the value of the stock at the end of a year. % Initialize the stock value S = zeros(1, 52); S(1) = 1; % Define the probability mass function p = [0.2, 0.4, 0.2, 0.2]; % Define the changes in stock value changes = [-0.2, 0, 0.2, 0.4]; % Simulate the stock value over one year for i = 2:52 % Generate a random number r = rand; % Determine the change in stock value if r < p(1) change = changes(1); elseif r < sum(p(1:2)) change = changes(2); elseif r < sum(p(1:3)) change = changes(3); else change = changes(4); end % Update the stock value S(i) = S(i-1) * (1 change); end % Plot the stock value over time plot(1:52, S); xlabel('Week'); ylabel('Stock Value'); title('Stock Value Over One Year')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!