# Repeated Bayesian filter

1. Feb 18, 2014

### carllacan

We have a sensor that measures a certain value that lies in the range (0, 3). The sensor is not perfect, and sometimes it fails. When this happens it ouputs a value under 1, regadless of the actual value. The failure probability is 0,01.

Suposing the sensor outputs a value under 1, what is the probability that the actual value is below 1? Suposing that we repeat the measurement N times and we always obtain a value under 1 what is the probability that the actual value is below 1?

My attempt at a solution:

Call a the actual value, and s the measured value. Then $P(a<1) = \frac{1}{3}$ and $P(a>1) = \frac{2}{3}$.Also $P(s<1|a<1) = 1$, $P(s<1|a>1) = 0.01$ and so $P(s<1) = P(s<1|a<1)*P(a<1) + P(s<1|a>1)*P(a>1) = 1 \frac{1}{3}+0.01 \frac{2}{3} = 0.34$ .

Using the Bayes Theorem $P(a<1|s<1) = \frac{P(s<1|a<1)P(a<1)}{P(s<1)} = \frac{1/3}{0.34} = 0.98$

When we get to the N measuremetns case I start having problems. Intuitively I think that measurement failures are independent of each other, that is, a faulty first measurement does not influence the probability of a faulty second measurement, and so on. Then the answer would simply be $P(a<1| s_{1:N} < 1) = 0.98^N$. It seems though misleadingly simple.

Could you help me out?

Last edited: Feb 18, 2014
2. Feb 18, 2014

### stlukits

You need to distinguish between the event "s<1" ($S_{i}$) and the event "failure" ($F_{i}$). The $F_{i}$ may be independent, but the $S_{i}$ are certainly not, since they measure the value. Your result would imply that a repeated measurement of s<1 actually decreases the chance of a<1, which is absurd. Let A be the event "a<1". Then

$$\label{eq:r1} P(A|S_{1}\wedge{}S_{2})= P(A|S_{1}\wedge{}S_{2}\wedge{}F_{1}\wedge{}F_{2})P(F_{1}\wedge{}F_{2})+ P(A|S_{1}\wedge{}S_{2}\wedge{}F_{1}\wedge\urcorner{}F_{2})P(F_{1}\wedge\urcorner{}F_{2})+$$

$$\label{eq:r2} P(A|S_{1}\wedge{}S_{2}\wedge\urcorner{}F_{1}\wedge{}F_{2})P(\urcorner{}F_{1}\wedge{}F_{2})+ P(A|S_{1}\wedge{}S_{2}\wedge\urcorner{}F_{1}\wedge\urcorner{}F_{2}) P(\urcorner{}F_{1}\wedge\urcorner{}F_{2})=$$

$$\label{eq:r3} \frac{1}{30000}+\frac{9999}{10000}=\frac{29998}{30000}$$

Now, that's more like it. The more often you measure "s<1" the more
unlikely $\urcorner{}A$ becomes.

Last edited: Feb 18, 2014
3. Feb 18, 2014

### carllacan

I understand your solution, but, don't you have to use another time the Bayes Theorem? Like "on top" of the first result? This comes from a introduction to recursive Bayesian filters, so I "feel" like there should be an iterative procedure. Or am I wrong?

4. Feb 18, 2014

### stlukits

Last edited: Feb 18, 2014
5. Feb 18, 2014

### carllacan

I understand that there is no need, but this is the foundation for more complicated problems. Namely problems in which we have a probability distribution over many values and the reality is influenced by probabilistic actions. Or, mathematically, we have $p(z_t| x_t )$ and $p(x_t| u_t )$.

In the case of this problem:

$p(z_t| x_t )$ becomes
$if x_t < 1:~~ p(z_t|x_t) = 1 for z_t < 1 and 0 for z_t > 1$
$if x_t > 1:~~ p(z_t|x_t) = 0.01 for z_t < 1 and 0.99 for z_t > 1$

And $p(x_t| u_t )$ is just $p(x)$.

Later on these distributions will be far more complicated, so I need to understant the general method, aplied to this problem, in order to better understand more advanced things.

6. Feb 18, 2014

### FactChecker

As stlukits says, even if the probabilities of failures are independent, the probabilities of the true values being less than one may not be. Although the problem is stated as though there is one identical true value for all the trials, when you multiply the Bayesian probabilities, you are assuming the true values are independent for all measurements. If there is one true value, your calculation must change.

P(true value < 1 | all N measurements < 1) = P( (true value < 1) and (all N measurements < 1))/P(all N measurements < 1)

This is still a direct application of Bayes' Rule.

7. Feb 19, 2014

### D H

Staff Emeritus
stlukits was correct in that your original answer is wrong. A long string of readings of values less than one is strongly indicative that the true value is indeed less than one. It is the probability that the true value is greater than one that should be decreasing. After that, I don't know what stlukits was calculating. His result is incorrect.

I'll look at the sample space as the set cross product of (true value ≥ 1, true value <1) and (sensor read true, sensor failed):
• The true value is greater than one and the sensor read true,
• The true value is greater than one and the sensor failed,
• The true value is less than one and the sensor read true,
• The true value is less than one and the sensor failed.
Note that a sensor reading of less than one excludes the first outcome. The only way to have a true value greater than one and a sensor reading less than one is if the sensor failed. This suggests that you look at the opposite of the problem than you were asked to look at: What is the probability that the true value is greater than one given a sensor reading that was less than one? Try using Bayes' Law to calculate this probability. The probability that the true value is less than one is one minus this calculated probability.

To calculate the probability that the true value is greater than one given two readings that are both less than one, you simply change the prior probability from your default prior based on the principle of indifference to the probability you calculated above for a true value greater than one given a single reading less than one. Similarly, the probability that the true value is greater than one given n readings all of which are less than one, you change the prior to the probability of n-1 successive sub-unity readings.