对每个相邻位置 i,i+1(共 n−1 对)设指示变量 Ii 表示该对异色,则期望为
E[i=1∑n−1Ii]=(n−1)P(相邻两位异色).
在随机排列中
P(RB)=na⋅n−1b,P(BR)=nb⋅n−1a,
因此
P(异色)=n(n−1)2ab.
代回得到
E[#异色相邻对]=(n−1)⋅n(n−1)2ab=a+b2ab.
英文解析
For each adjacent pair of positions i,i+1 (there are n−1 such pairs), let the indicator variable Ii represent whether the pair has different colors. Then the expectation is
E[i=1∑n−1Ii]=(n−1)P(adjacent two are different colors).
In a random permutation,
P(RB)=na⋅n−1b,P(BR)=nb⋅n−1a,
therefore
P(different colors)=n(n−1)2ab.
Substituting this back yields
E[#different color adjacent pairs]=(n−1)⋅n(n−1)2ab=a+b2ab.