Say I have some list a. It is an increasing, noisy dataset; something like $a x + X$ where $X$ is a noisy variable. This is as expected from what I'm interested in. However, once every so often my dataset has an extreme ourlier: if we take a zoom in of the list, a = {1,1.2,1.4,1.1,0.9,4,0.9,1.1}
, we see that there is suddenly a 4, which is unphysical in my situation. I know what's causing this issue, but I can't really get rid of it before post processing, so I will have to handle it this way.
In any case, what I'm looking for is a command that I could use to replace this 4, or more generally, every value $a_i > b a_{i-1}$ for some parameter $b$ that I can set. Moreover, I'd like the replacement to be such that $a_i = \frac{a_{i-1}+a_{i+1}}{2}$; I want to replace the point by the mean of its neighbours.
Now, I'm thinking this probably starts with something like creating a list of the fractions, where I divide each element by the value of the previous one. Then the comparison has to be made, and then the replacement. But to be honest I'm not quite sure of the most efficient way to tackle this.
Edit: as pointed out in the comments, the boundaries can be tricky. To keep it simple I'd just assume that they are not the problematic points and leave them as they are.
PartitionMap
then. $\endgroup${4,0.9,1.1,1}
? $\endgroup$