A puzzle of two unreliable sensors
jacobbrazeal.wordpress.com
jacobbrazeal.wordpress.com
Note that if a = 0 and b = 1 -> we KNOW b!=x because a is too small - there is no u with (u + 1) / 2 = 0. I'll skip the full calculation here, but basically if b could feasibly be correct its "atomic weight" ends up being as least as large as 0.5, so it is the posterior median, otherwise we know b is just noise, and the median is just a. So our estimator is
b if a in range [b/2, (b+1)/2]; a otherwise
This appears to do better than OPs solution running an experiment of 1M trials (MAE ~ 0.104 vs 0.116, I verify OPs numbers). The estimator to minimise the mean squared error (the maximum likelihood estimator) is more interesting - on the range a in [b/2, (b+1)/2] it becomes a nonlinear function of a of the form 1 / (1 + piecewise_linear(a)).
> U is uniform random noise over the same domain as P
> samples of P taken uniformly from [0, 1)
I have concluded that U ~ Uniform(0,1) and X ~ Uniform(0,1). i.e., U and X are i.i.d. Once I have that, then there is never any way to break the symmetry between X and U, and B always has a 50% chance of being either X or U.
Kalman filters are good where you have a system with a state, and an estimate of the state, and you act on the system, and then you measure the outcome, repeatedly.
Acting on the system and propagating your estimate forward "one step" increases the uncertainty of your estimate, and measuring decreases the uncertainty of your estimate.