Consider :
list = {100,102,103,99,106,107,104,112}
I want to consider, extract only the "big moves" of that time series. In this case the moves bigger then 5 from the moving point of reference.
The pseudo code would go as such :
Let's assume you have the data x(t)
for t=1
to T
,
You start from the first data point, z(1) = x(1)
if abs(x(2)-z(1))> delta,
z(2)= x(2),
elseif abs(x(3)-z(1))> delta,
z(2)= x(3),
elseif abs(x(4)-z(1))> delta,
z(2)= x(4),
if abs(x(5)-z(2))> delta,
z(3)= x(5),
elseif abs(x(6)-z(2))>delta,
z(3)= x(6),
if abs(x(7)-z(3))>delta,
z(4)=x(7)
endif
endif
endif
I tried to write it with an If
statement, but I don't know when my test is going to pass thus, how many If
s to nest.
If[Abs[list[[2]]-list[[1]]]>5,
list[[2]],
If[Abs[list[[3]]-list[[1]]>5,
list[[3]]....
Here this process will stop at list[[5]]
with Abs[list[[5]]-list[[1]]=6
At this point, list[[5]]
becomes my new point of reference :
If[Abs[list[[6]]-list[[5]]]>5,
list[[6]],
If[Abs[list[[7]]-list[[5]]>5,
list[[7]]....
So my desired output is the following :
{100,106,112}
I am pretty sure, this type of operation has a name but I don't know it. It felt like a While[]
or For[]
but I can`t figure it out. Please let me know how to improve the question.
) instead of an apostrophe (') in contractions. For example "don
t" instead of "don't", which causes problems with the formatting of your posts. $\endgroup$KagiChart
andRenkoChart
which have similar behavior. It's not easy to clearly and concisely describe them either. $\endgroup$