clear close all clc %Vitezstvi Barcelona 0.4 %Remiza 0.25 %Vitezstvi Real 0.35 %0-2 golu 0.5 %3+ 0.5 %?1-p(0:i,i:0,0:0) S = 1000000; gmax = 12; %max pocet golu results = zeros(S,1); goals = zeros(S,1); goals_B = zeros(S,1); goals_M = zeros(S,1); for s=1:S %urceni vysledku pom = rand; results(s)=(pom<=0.4)+(pom<=0.65)-1; %1 pro B, 0 remiza, -1 pro R logical = 0; %test konzistence vysledku pom_g = rand; %generovani celkoveho poctu golu (0-2 nebo 3-gmax) while logical==0 pom_ng = rand; %generovani poctu golu v ramci jednotlivych mnozin %stejna pravdepodobnost vstreleni kazdeho z golu goals(s) = (pom_g<=0.5)*((pom_ng<=1/3)+(pom_ng<=2/3))+... (pom_g>0.5)*(2+ceil(pom_ng*(gmax-2))); if (results(s)==0 && (rem(goals(s),2)==0)) || (results(s)~=0 && (goals(s)~=0)) logical = 1; end end if (results(s)==0) goals_B(s) = goals(s)/2; goals_M(s) = goals(s)/2; elseif (results(s)==1) goals_B(s) = 1+fix(goals(s)*(rand*0.5+0.5)); goals_M(s) = goals(s)-goals_B(s); elseif (results(s)==-1) goals_M(s) = 1+fix(goals(s)*(rand*0.5+0.5)); goals_B(s) = goals(s)-goals_M(s); end end %% 1-p(0:i,i:0,0:0) p=1-(sum(goals_M==0)+sum(goals_B==0)-sum((goals_B==0).*(goals_M==0)))/S; disp('Pravdepodobnost golu pro kazdy tym') disp(p); disp('Ferovy kurz na sazku vstreleni golu kazdym z tymu') disp(1/p);