Ray Vickson said:
Often, that type of discrepancy is just a result of using floating-point numbers instead of exact rationals, so you get inevitable roundoff errors. Perhaps that is what you are seeing?
The way I have done it is really over complicated compared to your solution.
Man has to choose at each try between
(0,B) for butter incorrect,
(1,B) for butter correct,
(0,M) for margarine incorrect,
(1,M) for margarine correct,
therefore the random experiment is a uniform choice among the ## (m_1,...,m_{18}) ## such that
if ## k_1 ## (resp. ##k_2##, ##k_3##, ##k_4##) denotes the number of (1,B) ( resp. (0,M), (1,M), (0,B) ),
we have ## k_1 + k_2 = 8 ## and ## k_3 + k_4 = 10 ##.
We call ##\Omega ## this set.
Then calling ## I = \{ k_1,k_2,k_3,k_4:\ k_1 + k_2 = 8, \ k_3+k_4 = 10 \} ##, the cardinal of ##\Omega## is :##|\Omega| = \sum_I { 8 \choose k_1 }{ 8-k_1 \choose k_2}{ \max ( 18 - k_1 -k_2 , 10 ) \choose k_3 }{ 10 - k_3 \choose k_4} = \sum_I { 8 \choose k_1 }{ 10 \choose k_3 } = \sum_{0 \le k_1 \le 8} { 8 \choose k_1} \sum_{0 \le k_3 \le 10} { 10 \choose k_3} = 2^8.2^{10} = 2^{18} ##
For event ## \{ Y = k_1 \} ##, writing ##J_{k_1} = \{ k_2,k_3,k_4: \ k_2 = 8 -k_1, \ k_3+k_4 = 10 \} ## we have
## |Y = k_1 | = { 8 \choose k_1 } \sum_{J_{k_1}} { 8-k_1 \choose k_2}{ \max ( 18 - k_1 -k_2 , 10 ) \choose k_3 }{ 10 - k_3 \choose k_4} = 2^{10} . { 8 \choose k_1 } ##
Giving ##P(Y= k_1 ) = \frac{2^{10} . { 8 \choose k_1 }}{2^{18}} = 2^{-8} { 8 \choose k_1 } ##
and ##Y ## is a ##B(8,1/2)##