问题:64人参加淘汰赛,其中21人为A国人,如果随机安排对阵,有n场内战的概率f(n)为多少?
n=21; % number of players from nation A
m=32; % number of games
nexp=100000; % number of experiments
ninter=zeros(nexp,1); % number of games between A nation players
for j=1:nexp
positions=zeros(m,2); % player nationality in each position
for i=1:n
ind=floor(rand(1,1)*(m*2-i+1))+1; % the index of a random available position
ind1=find(positions==0,ind); % the absolute index in position matrix
positions(ind1(end))=1;
end
ninter(j)=length(find(sum(positions,2)==2));
end
nmax=max(ninter);
p=histc(ninter,0:nmax)/nexp;
结果为,
0 0.00667
1 0.0579
2 0.18809
3 0.3073
4 0.26885
5 0.12994
6 0.03605
7 0.0048
8 0.0004
有三对内战的概率最高,有0.31,四对的概率次之,为0.27.
附:本次BC卡杯围棋赛,本赛64人,其中中国21人,分组抽签居然有五对内战,看来运气很差啊。