If I have a list
lst = {1, 2, 3, 4, 5};
Is there some way of taking the first element and then comparing it to the average of the other 4
elements? Then to take element 2
and compare it to the average of elements 1, 3, 4, 5
? I can see how to do this with a For
loop and a procedural style, but I am wondering if an easy functional style solution is possible.
Similar to this:
1 == Mean[{2, 3, 4, 5}]
2 == Mean[{1, 3, 4, 5}]
3 == Mean[{1, 2, 4, 5}]
P.S. I plan on using a more elaborate comparison, but ==
seemed like an easy one for this example.
lst
have duplicate elements? $\endgroup$MeanFilter[lst, 2] - lst
? That way you can play with different smoothing filters, too (e.g.GaussianFilter
,MedianFilter
) $\endgroup$