Probability - XOR of subset There are 15 numbers (546,861,69,868,751,562,755,43,989,120,35,947,601,651,935) and you have to create a subset of those.
0.5,0.5,0.1,0.4,0.6,0.5,0.2,0.1,0.1,0.8,0.8,0.2,0.3,0.5,0.7 are the respective probabilities to include them in the subset.
Find the expected XOR of the subset.
I am using this algorithm to solve: https://discuss.codechef.com/t/expxor-editorial/25883 as I find both the questions very similar, but I am not getting the correct answer.
511.5 is what I got, but it's incorrect. Edit: This turned out to be correct, the answer checker had a glitch.
Any help will be appreciated.
If you think each of the ten bits has a probability of about $0.5$ of surviving the XORs then the expectation should be about $\frac{2^{10}-1}2=511.5$
If you think each of the ten bits has a probability of exactly $0.5$ of surviving the XORs then the expectation should be exactly $\frac{2^{10}-1}2=511.5$
Four of the values have a probability of $0.5$ of going into the $XOR$ calculation.  Written in binary they are
546   1000100010
861   1101011101
562   1000110010
651   1010001011

and by observation each of the ten bits appears in at least one of these.
So we can conclude that $511.5$ is the correct answer.  To confirm, here is some R code which considers all the of the $2^{15}$ possibilities and their associated probabilities, confirming $511.5$
values &lt;- c(546,861,69,868,751,562,755,43,989,120,35,947,601,651,935)
probs &lt;- c(0.5,0.5,0.1,0.4,0.6,0.5,0.2,0.1,0.1,0.8,0.8,0.2,0.3,0.5,0.7)
combovalues &lt;- 0
comboprobs &lt;- 1

for (n in 1:length(values)){
  combovalues &lt;- c(combovalues, bitwXor(combovalues, values[n]))
  comboprobs &lt;- c(comboprobs * (1 - probs[n]), comboprobs * probs[n])
  }

sum(combovalues * comboprobs) 
# 511.5
this was a question in the code decode event of haywire dude. I am from mcs and this is cheating. Thanks for participating!