Mathematica Asked on November 21, 2020
Let’s consider the time series:
seria={38, 30, 23, 23, 14, 27, 21, 37, 25, 10, 24, 3, 5, 2, 5, 4, 8, 6, 13, 14, 6, 11, 3, 3, 15, 8, 17, 31, 56, 28, 9, 9, 52, 43, 11, 4, 15, 10,7, 10, 7, 7, 10, 12, 35, 40, 13, 13, 5, 10}
fig1=ListPlot[seria -> Range[Length[seria]], Filling -> Axis]
We are looking for the visibility of each peak:
AbsoluteTiming[
lseria = Length[seria];
pary = {};
Do[
kmax = n;
q2 = seria[[kmax]];
If[IntegerQ[n/500] == True, Print[n]];
Do[
kmin = p;
q1 = seria[[kmin]];
q3 = Take[seria, {kmin + 1, kmax - 1}];
If[
kmin + 1 == kmax,
AppendTo[pary, {kmin, kmax}],
If[
Min[{q1, q2}] >= Max[q3],
AppendTo[pary, {kmin, kmax}],
If[
Max[{q1, q2}] >= Max[q3],
If[q1 < q2,
temp = {};
Table[
q5 = seria[[kmin + k]];
If[
q5 > q1,
AppendTo[temp, (q5 - q1)/k]], {k, 1, kmax - kmin - 1}
];
If[
Max[temp] < (q2 - q1)/(kmax - kmin),
AppendTo[pary, {kmin, kmax}]],
temp = {};
Clear[q5];
Table[
q5 = seria[[kmax - k]];
If[
q5 > q2,
AppendTo[temp, (q5 - q2)/k]], {k, 1, kmax - kmin - 1}
];
If[
Max[temp] < (q1 - q2)/(kmax - kmin),
AppendTo[pary, {kmin, kmax}]
]
]]]],
{p, 1, n - 1}], {n, 2, lseria}
(*Label["end1"]*)
];
]
Nest,
k = Sort[Join[pary, Map[({#[[2]], #[[1]]}) &, pary]]]
The set ‘k’ contains all the visibility of each peak e.g. peak ‘no.2’ see the {1, 3, 4, 6, 8} peaks – see fig.1.
On the basis of ‘k’ we can create a graph:
k1 = Map[(#[[1]] [UndirectedEdge] #[[2]]) &, k];
graph = Graph[k1]
The question is: how to recreate the ‘series’ set on the basis of this graph (set ‘k’)?
Of course, identical values will not be kept 🙂
What does 29 see? In the set ‘k’ there are values for 29: {29, 1}, {29, 8}, {29, 9}, {29, 11}, {29, 12}, {29, 13}, {29, 14}, {29, 15}, {29, 17}, {29, 19}, {29, 20}, {29, 21}, {29, 22}, {29, 23}, {29, 25} . {29, 26}, {29, 27}, {29, 28}, {29, 30}, {29, 31}, {29, 32}, {29, 33}, {29, 46}.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP