martingale
% MARTINGALE returns and plots a cashflow using the Martingale system in roulette
%
% [outcomes] = martingale(initbet, betuntil, maxbet, gamblercash,
% casinocash, betfactorfactor, totalnumberofbets, wheeltype)
%
% where:
%
% outcomes(:,1) cashflow of the casino
% outcomes(:,2) cashflow of the gambler
% outcomes(:,3) bets
%
% For instance, you can use the following values:
%
% initbet = 5; (initial bet)
% betuntil = 17; (type of bet using the interval [0,37])
% maxbet = 10000; (maximum bet allowed on roulette table)
% gamblercash = 1000; (maximum in total the gambler can spend)
% casinocash = 1000000; (maximum in total the casino can spend)
% betfactorfactor = 2; (when you double, use 2)
% totalnumberofbets = 100; (total number of bets: stopping criterium)
% wheeltype = 1 (1 = American, else French roulette)
% output = 0; (1 = generate plots, else do not)
%
% It also plots three figures using outcomes.
%
% Typical roulette bets are:
%
% betuntil bet type
% 0 straight up
% 1 split
% 2 trio
% 3 corner
% 4 five-number
% 5 six-number
% 11 column/dozen
% 17 even-odd/high-low/red-black
%
% You can use MARTINGALE for example in the following manner:
%
% numberofgamblers = 1000; % number of gamblers involved
% totalgamblerprofits = 0; % total amount of profit so far
% outcome = zeros(totalnumberofbets, 3); % to store individual results
% results = zeros(numberofgamblers, 4); % to store cumulative results
%
% for gamblernumber = 1:numberofgamblers
% outcome = martingale(initbet, betuntil, maxbet, gamblercash, casinocash, betfactorfactor, totalnumberofbets, wheeltype, output);
% casinocash = outcome(end,1); % update cash of casino
% totalgamblerprofits = totalgamblerprofits + (outcome(end,2) - gamblercash); % add profits
% results(gamblernumber,:) = [gamblernumber casinocash totalgamblerprofits totalgamblerprofits/numberofgamblers];
% end
%
% plot(results(:,4)); % plot average profit per gambler
% hold on;
% xlabel('number of gamblers gambled');
% ylabel('average profit per gambler');
% hold off;
%
% For further reading on this betting system see:
% http://en.wikipedia.org/wiki/Martingale_(betting_system)
Cite As
Peter-Paul van Maanen (2024). martingale (https://www.mathworks.com/matlabcentral/fileexchange/20137-martingale), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.