Code covered by the BSD License

Chapter 1 Exercises of Introduction to Probability

Bilal Siddiqui (view profile)

Matlab Implementation of Introductory Probability

HTsimulation.m
```%HTsimulation

%Peter wins every time a head turns up

%Peter is in the lead when his winnings are positive.When Peters winnings are 0,...
%he is in the lead if he was ahead at the previous toss

%%
clc;clear all;close all;
tosses=40;
out=rand(tosses,1);
for i=1:tosses
if earnings(i+1)>0 || (earnings(i+1)==0 && earnings(i)>0)
else
end
end

xlabel('Number of tosses');legend('Earnings (pennies)','Peter in lead');
title('Peter wins a penny everytime a head turns up and loses one otherwise');
%%

clc;clear all;
tosses=40;
experiments=10000;

out=rand(tosses,experiments);

figure;
hist(earnings,-tosses:2:tosses);grid;
xlabel('Pennies earned');ylabel('Percentage of Occurence');
title('Win Distribution');

%%

for i=1:experiments
for j=1:tosses
if earnings(j+1,i)>0 || (earnings(j+1,i)==0 && earnings(j,i)>0)
else