Created
August 31, 2020 01:59
-
-
Save JanDW/67d70ecb54bf186622f2a201e01a02ea to your computer and use it in GitHub Desktop.
Runs a Monte Carlo experiment of the Boonie simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Runs a Monte Carlo experiment of the Boonie simulation | |
% | |
% | |
% Input(s) | |
% nMC: Number of Monte Carlo iterations | |
% | |
% Output(s) | |
% Days: Vector of days until Boonie gets caught | |
% | |
% Example: | |
% Days = boonie_Monte_Carlo(1000); | |
% | |
% See also: boonieSim | |
% | |
% | |
% Dependencies: pubFig | |
% | |
% | |
% Written by: John Peach 28-Aug-2020 | |
% Marakesh Sailing Analysis and Design | |
% | |
% Revisions: | |
function Days = boonie_Monte_Carlo(nMC) | |
% Initialize Days vector | |
Days = zeros(1,nMC); | |
% Run the Monte Carlo experiments | |
hdl = waitbar(0,'Boonie Monte Carlo'); | |
for k = 1:nMC | |
% Run one instance | |
Days(k) = boonieSim; | |
% Update waitbar | |
waitbar(k/nMC,hdl); | |
endfor | |
% Close the waitbar | |
close(hdl); | |
% Plot a histogram of the days | |
figure; | |
hist(Days,50); | |
xlabel('Days'); | |
ylabel('Number of times'); | |
title('Monte Carlo Conspiracy Simulation') | |
pubFig | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment