clear; clc;
%% nahrání dat
format long
%počet scénářů
ng=[20 40 60 80 100 120 140 160 180 200];

%náhodný výběr
[V(1),H(1), D(1), I(1)] = SampleInfo('results_20.xls', 0.05);
[V(2),H(2), D(2), I(2)] = SampleInfo('results_40.xls', 0.05);
[V(3),H(3), D(3), I(3)] = SampleInfo('results_60.xls', 0.05);
[V(4),H(4), D(4), I(4)] = SampleInfo('results_80.xls', 0.05);
[V(5),H(5), D(5), I(5)] = SampleInfo('results_100.xls', 0.05);
[V(6),H(6), D(6), I(6)] = SampleInfo('results_120.xls', 0.05);
[V(7),H(7), D(7), I(7)] = SampleInfo('results_140.xls', 0.05);
[V(8),H(8), D(8), I(8)] = SampleInfo('results_160.xls', 0.05);
[V(9),H(9), D(9), I(9)] = SampleInfo('results_180.xls', 0.05);
[V(10),H(10), D(10), I(10)] = SampleInfo('results_200.xls', 0.05);
%IRN
[XI(1),U(1),L(1),eps_u(1), eps_l(1), conf(1)] = IRN('results_20.xls', 0.05);
[XI(2),U(2),L(2),eps_u(2), eps_l(2), conf(2)] = IRN('results_40.xls', 0.05);
[XI(3),U(3),L(3),eps_u(3), eps_l(3), conf(3)] = IRN('results_60.xls', 0.05);
[XI(4),U(4),L(4),eps_u(4), eps_l(4), conf(4)] = IRN('results_80.xls', 0.05);
[XI(5),U(5),L(5),eps_u(5), eps_l(5), conf(5)] = IRN('results_100.xls', 0.05);
[XI(6),U(6),L(6),eps_u(6), eps_l(6), conf(6)] = IRN('results_120.xls', 0.05);
[XI(7),U(7),L(7),eps_u(7), eps_l(7), conf(7)] = IRN('results_140.xls', 0.05);
[XI(8),U(8),L(8),eps_u(8), eps_l(8), conf(8)] = IRN('results_160.xls', 0.05);
[XI(9),U(9),L(9),eps_u(9), eps_l(9), conf(9)] = IRN('results_180.xls', 0.05);
[XI(10),U(10),L(10),eps_u(10), eps_l(10), conf(10)] = IRN('results_200.xls', 0.05);
%CRN
[XC(1),G(1),eps_g(1), confg(1), g(:,1)] = CRN('results_20.xls', 0.05);
[XC(2),G(2),eps_g(2), confg(2), g(:,2)] = CRN('results_40.xls', 0.05);
[XC(3),G(3),eps_g(3), confg(3), g(:,3)] = CRN('results_60.xls', 0.05);
[XC(4),G(4),eps_g(4), confg(4), g(:,4)] = CRN('results_80.xls', 0.05);
[XC(5),G(5),eps_g(5), confg(5), g(:,5)] = CRN('results_100.xls', 0.05);
[XC(6),G(6),eps_g(6), confg(6), g(:,6)] = CRN('results_120.xls', 0.05);
[XC(7),G(7),eps_g(7), confg(7), g(:,7)] = CRN('results_140.xls', 0.05);
[XC(8),G(8),eps_g(8), confg(8), g(:,8)] = CRN('results_160.xls', 0.05);
[XC(9),G(9),eps_g(9), confg(9), g(:,9)] = CRN('results_180.xls', 0.05);
[XC(10),G(10),eps_g(10), confg(10), g(:,10)] = CRN('results_200.xls', 0.05);

%vykreslení rozdílů g
figure()
plot(ng,g,'*')
xlabel('počet scénářů')
xlim([10 210])
ylabel('G')

%% vykreslení intervalu spolehlivosti
%IRN
figure()
plot(ng, L,'*', ng, U, '*', ng, L-eps_l,'s', ng, U+eps_u, 's', 'MarkerSize',8  )
title('interval spolehlivosti - IRN')
legend('dolní odhad', 'horní odhad','dolní odhad s chybou', 'horní odhad s chybou') 
xlabel('počet scénářů')
xlim([10 210])
ylabel('výdaje')

%CRN
figure()
plot(ng, G,'*', ng, G+eps_g,'s', 'MarkerSize',8)
title('interval spolehlivosti - CRN')
xlabel('počet scénářů')
xlim([10 210])
ylabel('G')
legend('horní odhad G', 'horní odhad G s chybou')

%náhodný výběr
%figure()
figure()
plot(ng, D,'*b', ng, H, '*g', ng, V, '+r' , 'MarkerSize',8)
title('interval spolehlivosti - NV')
legend('dolní mez', 'horní mez', 'průměr')
xlabel('počet scénářů')
xlim([10 210])
ylabel('výdaje')

%%% vykreslení velikosti intervalu spolehlivosti
figure()
bar(ng,[conf; confg; I].')
title('rozsah intervalu spolehlivosti')
legend('IRN','CRN','NV')
xlabel('počet scénářů')
ylabel('rozsah')
