3

I have a piece of code that takes a noisy data set and uses some sort of statistical filter to plot a trend line over the noisy data. The original author of the code no longer works at my job, so I can't ask him what the filter is. I've included a math-ified version of his code, and I would love to know what the filter is called so I can learn more about it. Here's a code/math snippet.

First, a bunch of variables are set. The first element of filtered is set to just be the average of the noisy data, just so we have a value to use in the first iteration of the loop. filtered will contain all the filtered points from the noisy dataset called noisy.

$\beta = 0.00001 \\ \sigma = 0.005 \\ \overline{p}_0 = 1 \\ q = 1 \\ k = \frac{\overline{p}_0}{\overline{p}_0 + 1} \\ p = k \\ filtered[0] = avg(noisy)$

Then, we enter a loop, and forgive me if this is a little confusing. For each element $i$ in noisy, do the following things:

$m_i = e^{-\beta} \\ \gamma = \sqrt{\frac{\sigma^2(1-m_i^2)}{2\beta}} \\ \phi = m_i \\ \overline{\eta} = \phi \cdot filtered(i) \\ \overline{p}_i = \phi \cdot p \cdot (\phi + \gamma) \cdot q \cdot \gamma \\ k = \frac{\overline{p}_i}{\overline{p}_i + 1} \\ filtered[i] = \overline{\eta} + k \cdot (noisy[i] - \overline\eta) \\ p = k$

Does anyone recognize anything from this math/code sample? The filter seems to work (I wrote a simple moving average filter and compared the two and it looks pretty good to me). Thanks in advance!

0 Answers0