
Np=1000;
bet=linspace(0,1,Np);
gain=zeros(1,Np);
N_games=200;


% Notice that once we fix number of games to play,
% bet outcome will be the function of only the bet fraction.
% I will create an anonymous function to deal with it
game_gain = @(bet) bet_outcome(bet, N_games); 
% notice that in above function definition bet acts as a variable to be used
% but not a certain value of previously defined bet=linspace(...).
% Yep, it is very confusing sometimes.

% Now we would like to make a vector  of game gains 
% as function of the input bets vector.
% The problem here that our bet_outcome(bet, N_games) function is not suited
% for a vector as the input parameter. 
% As result game_gain(bet) function is not suited as well. 
% So we need either loop over all possible values of the bet vector or
% better use arrayfun.
gain = arrayfun(game_gain, bet);

semilogy(bet, (gain),'-'); % gain or loss after series of gambles
hold on; 
semilogy(bet, 1, 'r-'); % plots no gain situation, 
xlabel('bet fraction');
ylabel('gain');
title('gain vs bet');
hold off;




