You know the probability that an object is dirty. An unreliable sensor tells you its true state. What is the new probability that the object is dirty?

68 Views Asked by At

I have encountered a statistics related problem for an AI project that I don't know how to solve, but I'm also nearly statistically illiterate so I'm not sure where to look. Hoping I can get a tip here.

I'll also explain things mostly as a programmer, since if I try to use statistical terms and notation I will likely offend someone.

Problem
Suppose you know the probability that an object is dirty: pDirty
Then use a dirt sensor which tells you if the object is actually dirty or not dirty.
However, the sensor has a chance to be wrong. You know the probability that the sensor will fail: pSensorFail

With an initial pDirty, a sensor value sensor (0 or 1), and pSensorFail, how should you update pDirty given this new information?

Scenarios
If pDirty is 1 or 0, we already know the dirty state. So we ignore the sensor.
If pSensorFail is 0 then the sensor is perfect, and you should set pDirty = sensor
If pSensorFail is 1 then the sensor is still perfect, its just always wrong. You should set pDirty = 1 - sensor
If pSensorFail is 0.5, then the sensor is basically random and useless, and you should ignore it.

I'm wondering how to handle all other cases?
I assume there is some statistics formula that is correct 8for any pDirty, sensor, pSensorFail

Experiments
One strategy to reduce the cases a bit is
if pSensorFail > 0.5, set pSensorFail = 1 - pSensorFail, sensor = 1 - sensor.

Then from this point you can assume 0 <= pSensorFail < 0.5

I thought of a measure of how much the sensor is "trusted":
sensorTrust = 2 * abs(pSensorFail - 0.5)
i.e if sensorTrust is 1 then the sensor is always correct, if sensorTrust is 0 then it is always wrong

Then I linearly interpolate pDirty to sensor by sensorTrust:
pDirty = Lerp(pDirty, sensor, sensorTrust)

This is working okay, but I feel like it doesn't respect the current pDirty enough.
For example if pDirty is 0 or 1 then we should actually ignore the sensor,
since we are already certain about the dirtiness.
Also, if pDirty is 0.5 then maybe the sensor should have an even greater effect?

Any help or tips would be very appreciated.

Thanks

1

There are 1 best solutions below

4
On BEST ANSWER

It seems to me that what you want is the usual Bayesian update: you have $P(D),P(D^c),P(S \mid D),P(S \mid D^c)$ where $D$ is "the object is dirty" and $S$ is "the sensor says that the object is dirty". Then if you get a dirty sensor result, you update your probability that the object is dirty according to

$$P(D \mid S)=\frac{P(S \mid D)P(D)}{P(S \mid D) P(D) + P(S \mid D^c) P(D^c)}.$$

If instead you get a clean sensor result:

$$P(D \mid S^c)=\frac{P(S^c \mid D)P(D)}{P(S^c \mid D)P(D) + P(S^c \mid D^c) P(D^c)}.$$

In your notation, $P(D)$ is pDirty, $P(D^c)$ is 1-pDirty, $P(S \mid D)$ and $P(S^c \mid D^c)$ are both 1-pSensorFail and while $P(S \mid D^c)$ and $P(S^c \mid D)$ are pSensorFail. These formulas correctly manage all the case work you mentioned, including the case when the sensor always gives the wrong answer.