Example 5.1
Estimating Probability and Expected Value
% Script Eg5_1
% Estimates the expected value of Gap(N) and the
% probability that Gap(N) <= 4N.
close all
clear
% Check N-values 1,2,.
..,maxN and base estimates on M games.
..
maxN = 10;
M = 1000;
for N = 1:maxN
E(N) = EVGap(N,M);
P(N) = P4NGap(N,M);
end
plot(E)
title(’Expected Value of Gap(N)’,’Fontsize’,14)
xlabel(’N’,’Fontsize’,14)
set(gca,’xTick’,linspace(1,maxN,maxN),’xTickLabel’,linspace(1,maxN,maxN))
ylabel(’Expected Value’,’Fontsize’,14)
axis([1 maxN 0 inf]); grid on
figure
plot(P)
title(’Probability that Gap(N) <= 4*N’,’Fontsize’,14)
xlabel(’N’,’Fontsize’,14)
set(gca,’xTick’,linspace(1,maxN,maxN),’xTickLabel’,linspace(1,maxN,maxN))
ylabel(’Probability’,’Fontsize’,14)
set(gca,’yTick’,linspace(0,1,11),’yTickLabel’,linspace(0,1,11))
axis([1 maxN 0 1]); grid on
Sample Output
1
2
3
4
5
6
7
8
9
10
0
10
20
30
40
50
60
70
80
90
Expected Value of Gap(N)
N
Expected Value
1
2
3
4
5
6
7
8
9
10
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Probability that Gap(N) <= 4*N
N
Probability
2