% ML4N 2021

function ExampleLecture1()

MaxIter=100;

% Strategy 1: I select one box at random, and I stady there 

box_selected = randi(2,1);
TotalRewardStrategy1 = 0;

for i=1:MaxIter
    if box_selected == 1
        TotalRewardStrategy1 = TotalRewardStrategy1 + Box1(); 
    else
        TotalRewardStrategy1 = TotalRewardStrategy1 + Box2();
    end    
end

disp('Strategy 1: Reward');
disp(TotalRewardStrategy1);


% Strategy 2: I select a box at random at every 'iteration'

TotalRewardStrategy2 = 0;

for i=1:MaxIter
    box_selected = randi(2,1);
    if box_selected == 1
        TotalRewardStrategy2 = TotalRewardStrategy2 + Box1(); 
    else
        TotalRewardStrategy2 = TotalRewardStrategy2 + Box2();
    end    
end

disp('Strategy 2: Reward');
disp(TotalRewardStrategy2);

% Strategy 3: Can I do it better?

% Any suggestion?


end

function R=Box1()

R = rand();

end

function R=Box2()

R = 0.5+rand();

end