Closed AL-JiongYang closed 11 months ago
Nice catch! Also, next time, if you want to, you can create a pull request, it would make sure that your name shows up as a contributor to the work! I added you in the comment, but that's not the same :)
Mate
The probability of generating random bits for XOR is not exactly 0.5.
As shown here, the function uniform_int_distribution uniformly samples a number from [0, 1000]. If the sampled number is less than 500, we generate 1; otherwise, we generate 0. The probability of generating 1 is 500/1001, while the probability of generating 0 is 501/1001. The probability is not as expected as 0.5.
Instead, we should sample from [0, 999] to obtain the probability of 0.5.