Hello again !
I have a small problem with my code. I had to create a dice with changed probabilites for each number where the number 3 had a probability of 1/5 (20%). The task was to count the number of times i get the number 3-three times in a row.
The probability for this should be in theory 0,2*0,2*0,2=0,008=0,8%. That means i should get my three 3s every 125 throws on average. The problem now is when i throw my dice now like a 100000 times i get a probability of only 0,15% and i cant find the reason why. Is my code wrong or is my theoretic probability wrong?
I coded it like this:
clcclear all;lastthrow = 0;threetimescounter = 0;counterbacktoback = 0;wurf = 0;for k = 1:1000000 if rand() <= 1/5 wurf = 3; if lastthrow == wurf %counter nacheinander gewürfelte 3
counterbacktoback = counterbacktoback + 1; %Inkrement, bis 3 erreicht wird, dann geht ein DREIERBLOCK Counter hoch. und das letzte dreierglied wird direkt weggenommen.
if counterbacktoback == 3 threetimescounter = threetimescounter + 1; counterbacktoback = counterbacktoback - 1; %Dekrement, weil der Letzte nichtig wird, und die ersten zwei 3er wieder auf den hypothetischen 4. 3er hoffen, der anschliessend mit den 2 letzten eine dreiergruppe darstellen koennte.
end else counterbacktoback = 0; end else wurf = 0; end lastthrow = wurf; endpthree3s=(((1/5)*(1/5)*(1/5)))*100;pthree3ssimul= (threetimescounter/1000000)*100;
Best Answer