Hi I am trying to simulate a betting system with the probability of "Player" wins with probability of 0.46686, "Banker" wins with probability of 0.42556, "Tie" wins with probability of 0.10758.
The gambler has the preference of betting Player:Banker:Tie on a probability 0.5:0.45:0.05, each time he lose he lower the probability he bet on by 10% and raise other 2 by 10%, vice versa.
When I simulate my file it gave me the error "??? Index exceeds matrix dimensions" which I can't find any mistake, please help me.
function BetProbability=TestProb
%Generate the results for each round by using the average of 100 probabilities
%estimated from the simulated 2000 rounds/. The probabilities obtain are:
%"Player" wins with probability of 0.46686, "Banker" wins with probability of
%0.42556, "Tie" wins with probability of 0.10758
for t=1:2000,
C(t) = ceil(100000*rand);
if C(t)>=1 & C(t)<=46686,
C(t)=1; %'1' signifies Player
elseif C(t)>=46687 & C(t)<=89242,
C(t)=2; %'2' signifies Dealer
else C(t)=3; %'3' signifies Tie
end
end
%Now we assume that a superstitious gambler don't believe our first generate and
%believe that all results are determined by God (or any other means), so he still
%keep on a same probability of betting. Player:Banker:Tie = 0.5:0.45:0.05
%However, his betting probability will change if he lose in the previous round
%For example, if he betted "Player" on the first round but lost, the probability
%of betting will change to 0.45:0.495:0.055
%If he win he will increase the probability betting on the same side by 10% and
%decrease others by 10%, vice versa
BetDecision=zeros(1,2000);
BetDecision(1)= ceil(10000*rand);
if BetDecision(1)>=1 & BetDecision(1)<=5000,
BetDecision(1)=1; %'1' signifies Gambler Betting Player
elseif BetDecision(1)>=5001 & BetDecision(1)<=9500,
BetDecision(1)=2; %'2' signifies Gambler Betting Dealer
else BetDecision(1)=3; %'3' signifies Gambler Betting Tie
end
BetProbability=zeros(3,2000);
BetProbability(:,1)=[0.5; 0.45; 0.05];
for k=2:2000,
if BetDecision(k1)==C(k1),
BetProbability(:,k)=BetProbability(:,k1)*0.9; BetProbability(BetDecision(k1),k)=BetProbability(BetDecision(k1),k)*1.1/0.9;
if BetDecision(k)>=1 & BetDecision(k)<=10000*BetProbability(k,1),
BetDecision(k)=0; %'0' signifies Gambler Betting Player
elseif BetDecision(k)>10000*BetProbability(k,1) & BetDecision(k)<=10000*(BetProbability(k,1)+BetProbability(k,2)),
BetDecision(k)=1; %'1' signifies Gambler Betting Dealer
else BetDecision(k)=2; %'2' signifies Gambler Betting Tie
end
else BetProbability(:,k)=BetProbability(:,k1)*1.1; BetProbability(BetDecision(k1),k)=BetProbability(BetDecision(k1),k)*0.9/1.1;
if BetDecision(k)>=1 & BetDecision(k)<=(10000*BetProbability(k,1)),
BetDecision(k)=0; %'0' signifies Gambler Betting Player
elseif BetDecision(k)>(10000*BetProbability(k,1)) & BetDecision(k)<=(10000*(BetProbability(k,1)+BetProbability(k,2))),
BetDecision(k)=1; %'1' signifies Gambler Betting Dealer
else BetDecision(k)=2; %'2' signifies Gambler Betting Tie
end
end
end
