Persistence1D là một lớp để tìm cực trị cục bộ và tính bền vững của chúng trong dữ liệu một chiều. Cực tiểu cục bộ và cực đại cục bộ được trích xuất, ghép nối và sắp xếp theo độ bền của chúng
Mã chạy trong thời gian O[n log n], trong đó n là số điểm đầu vào
Để làm mịn dữ liệu đầu vào ồn ào, công cụ này được ghép nối tốt nhất với Reconstruct1D. một công cụ để làm mịn dữ liệu một chiều dựa trên cấu trúc liên kết. Điều này cho phép tạo một hàm trơn tru chỉ chứa cực tiểu/cực đại có độ bền cao
Gói hỗ trợ C ++, Python và Matlab
Phiên bản C++ và Matlab của Persistence1D được viết bởi Yeara Kozlov và Tino Weinkauf, Viện Tin học Max Planck, Saarbrücken, Đức. Phiên bản Python đã được viết bởi Tino Weinkauf, Viện Công nghệ Hoàng gia KTH, Stockholm, Thụy Điển. Bạn có thể sử dụng nó theo ý muốn, nó thuộc phạm vi công cộng. Nếu bạn thấy nó hữu ích, rất vui được nghe từ bạn. Chỉ cần thả chúng tôi một dòng
Sự nổi bật của một đỉnh đo mức độ nổi bật của đỉnh do chiều cao nội tại của nó và vị trí của nó so với các đỉnh khác. Một đỉnh thấp bị cô lập có thể nổi bật hơn một đỉnh cao hơn nhưng lại là một thành viên không đáng chú ý của dải cao
Để đo sự nổi bật của một đỉnh
Đặt một điểm đánh dấu trên đỉnh
Kéo dài một đường ngang từ đỉnh sang trái và phải cho đến khi đường này thực hiện một trong các thao tác sau
Vượt qua tín hiệu vì có đỉnh cao hơn
Đạt đến đầu bên trái hoặc bên phải của tín hiệu
Tìm giá trị nhỏ nhất của tín hiệu trong mỗi khoảng trong hai khoảng được xác định ở Bước 2. Điểm này là một thung lũng hoặc một trong các điểm cuối tín hiệu
Mức cao hơn trong hai mức cực tiểu khoảng chỉ định mức tham chiếu. Chiều cao của đỉnh trên mức này là điểm nổi bật của nó
findpeaks
không đưa ra giả định nào về hành vi của tín hiệu ngoài các điểm cuối của nó, bất kể độ cao của chúng. Do đó, Bước 2 và 4 bỏ qua hành vi của tín hiệu ngoài các điểm cuối, điều này thường ảnh hưởng đến giá trị của mức tham chiếu. Ví dụ, xem xét các đỉnh của tín hiệu này
Số đỉnh Khoảng bên trái Nằm giữa Đỉnh và Khoảng bên phải Nằm giữa Đỉnh và Điểm thấp nhất ở khoảng bên trái Điểm thấp nhất ở khoảng bên phải Mức tham chiếu [Tối thiểu cao nhất]1 Điểm cuối bên tráiGiao nhau do đỉnh 2Điểm cuối bên tráiđiểm aa2Kết thúc bên tráiĐiểm cuối bên tráiĐiểm cuối bên tráiĐiểm cuối bên trái
Độ nổi bật của cực đại cục bộ [hoặc cực đại] đo mức độ nổi bật của cực đại đối với chiều cao và vị trí của nó so với các cực đại khác
Để đo độ nhô của một đỉnh, trước tiên hãy kéo dài một đường ngang từ đỉnh. Tìm nơi đường giao cắt dữ liệu ở bên trái và bên phải, đó sẽ là một đỉnh khác hoặc phần cuối của dữ liệu. Đánh dấu các vị trí này là điểm cuối bên ngoài của khoảng thời gian bên trái và bên phải. Tiếp theo, tìm thung lũng thấp nhất trong cả hai khoảng thời gian. Lấy phần lớn hơn trong hai thung lũng này và đo khoảng cách thẳng đứng từ thung lũng đó đến đỉnh. Khoảng cách này là điểm nổi bật
Đối với một vectơ x
, điểm nổi bật lớn nhất là max[x]-min[x]
Tiếp cận. Ý tưởng là lặp lại mảng đã cho arr[] và kiểm tra xem mỗi phần tử của mảng là nhỏ nhất hay lớn nhất trong số các phần tử liền kề của chúng. Nếu nó nhỏ nhất thì nó là cực tiểu địa phương và nếu nó lớn nhất thì nó là cực đại địa phương. Dưới đây là các bước
- Tạo hai mảng max[] và min[] để lưu trữ tất cả các cực đại cục bộ và cực tiểu cục bộ
- Duyệt qua mảng đã cho và nối chỉ số của mảng vào mảng max[] và min[] theo các điều kiện bên dưới
- Nếu arr[i – 1] > arr[i] < arr[i + 1] thì nối chỉ số đó vào min[]
- Nếu arr[i – 1] < arr[i] > arr[i + 1] thì nối chỉ số đó vào max[]
- Kiểm tra các điều kiện cực đại và cực tiểu cục bộ cho các phần tử đầu tiên và cuối cùng một cách riêng biệt
- In các chỉ mục được lưu trữ trong min[] và max[]
Dưới đây là cách triển khai của phương pháp trên.
C++
// C++ program for the above approach
#include
using
namespace
std;
________số 8
// and minima in the given array arr[]
x
0 x
1// C++ program for the above approach
0 // C++ program for the above approach
1// C++ program for the above approach
0 // C++ program for the above approach
3
// C++ program for the above approach
4
// C++ program for the above approach
5
// C++ program for the above approach
5// C++ program for the above approach
7
// C++ program for the above approach
5// C++ program for the above approach
9
// C++ program for the above approach
5#include
1____30#include
3
// C++ program for the above approach
5#include
5
// C++ program for the above approach
5#include
7
// C++ program for the above approach
5#include
9 using
0
using
1using
2
________ 35 ________ 54 ________ 49 ________ 56
using
1using
8
// C++ program for the above approach
5namespace
0
// C++ program for the above approach
5namespace
2
// C++ program for the above approach
5namespace
4namespace
5// C++ program for the above approach
0 namespace
7
// C++ program for the above approach
5// C++ program for the above approach
4
using
1
// C++ program for the above approach
5std;
2
// C++ program for the above approach
5#include
9 std;
5
using
1std;
7
using
1std;
9
using
1
// C++ program for the above approach
5// Function to find all the local maxima
2
________ 35 ________ 54 ________ 49 ________ 86
// Function to find all the local maxima
7// Function to find all the local maxima
8
using
1// and minima in the given array arr[]
0
// C++ program for the above approach
5// and minima in the given array arr[]
2
// C++ program for the above approach
5// and minima in the given array arr[]
4
// C++ program for the above approach
5#include
7
// C++ program for the above approach
5#include
9 // and minima in the given array arr[]
9
using
1x
01
________ 35 ________ 54 ________ 49 ________ 105
using
1x
07
// C++ program for the above approach
5x
09
// C++ program for the above approach
5x
11
// C++ program for the above approach
5#include
9 x
14
// C++ program for the above approach
5// C++ program for the above approach
4
using
1x
18x
19// C++ program for the above approach
00
using
1namespace
4namespace
5// C++ program for the above approach
0 // C++ program for the above approach
05
using
1// C++ program for the above approach
07____308// C++ program for the above approach
00
_______51____311
// C++ program for the above approach
5// and minima in the given array arr[]
2
________ 35 ________ 54
using
1____118// C++ program for the above approach
18
// C++ program for the above approach
19// C++ program for the above approach
20// C++ program for the above approach
21// C++ program for the above approach
00
// C++ program for the above approach
5#include
9 // C++ program for the above approach
25
// C++ program for the above approach
5// C++ program for the above approach
4
_______51____118____330// C++ program for the above approach
00
using
1____64____65// C++ program for the above approach
0 // C++ program for the above approach
36
using
1// C++ program for the above approach
07____308// C++ program for the above approach
00
_______51____311
// C++ program for the above approach
5// and minima in the given array arr[]
2
________ 35 ________ 54
using
1____118// C++ program for the above approach
18
// C++ program for the above approach
19// C++ program for the above approach
20// C++ program for the above approach
52// C++ program for the above approach
00
// and minima in the given array arr[]
2
// C++ program for the above approach
55
// C++ program for the above approach
0 // C++ program for the above approach
57
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
0 // C++ program for the above approach
61
// C++ program for the above approach
5// C++ program for the above approach
63
// C++ program for the above approach
5// C++ program for the above approach
0 // C++ program for the above approach
66
// Function to find all the local maxima
7// C++ program for the above approach
68
// C++ program for the above approach
5// C++ program for the above approach
70
// C++ program for the above approach
5// C++ program for the above approach
72
// C++ program for the above approach
5// C++ program for the above approach
74 // C++ program for the above approach
75
// and minima in the given array arr[]
2
// C++ program for the above approach
77
Java
// C++ program for the above approach
78
// C++ program for the above approach
79 // C++ program for the above approach
80
// C++ program for the above approach
81 // C++ program for the above approach
82
// C++ program for the above approach
5
________số 8
// and minima in the given array arr[]
________ 386 ________ 387 ________ 10 x
1// C++ program for the above approach
0 // C++ program for the above approach
1
// C++ program for the above approach
92____30// C++ program for the above approach
94
// C++ program for the above approach
4
// C++ program for the above approach
5
// C++ program for the above approach
5// C++ program for the above approach
7
// C++ program for the above approach
5// C++ program for the above approach
9
// C++ program for the above approach
5#include
02____403 #include
04
// C++ program for the above approach
5#include
06#include
03 #include
04
// C++ program for the above approach
5#include
5
// C++ program for the above approach
5#include
7
// C++ program for the above approach
5#include
9 #include
15#include
16#include
17#include
18#include
19
_______51____421____416#include
23
// C++ program for the above approach
5using
4 #include
9 #include
15#include
16#include
29#include
18#include
19
_______51____433____416#include
23
// C++ program for the above approach
5namespace
0
// C++ program for the above approach
5namespace
2
// C++ program for the above approach
5namespace
4namespace
5// C++ program for the above approach
0 #include
44#include
18#include
46#include
18#include
48
// C++ program for the above approach
5// C++ program for the above approach
4
using
1std;
2
using
1#include
9 #include
55#include
18#include
57
// C++ program for the above approach
19#include
59____418#include
61
// C++ program for the above approach
19#include
63
// C++ program for the above approach
19
using
1// Function to find all the local maxima
2
using
1using
4 #include
9 #include
55#include
18#include
72
_______87____474____418#include
61
// C++ program for the above approach
19#include
78
// C++ program for the above approach
5// and minima in the given array arr[]
2
// C++ program for the above approach
5// and minima in the given array arr[]
4
// C++ program for the above approach
5#include
7
// C++ program for the above approach
5#include
9 #include
87#include
18#include
89#include
90#include
19
using
1____493____418#include
23
// C++ program for the above approach
5using
4 #include
9 #include
87____418using
01#include
90#include
19
using
1____505____418#include
23
// C++ program for the above approach
5x
09
// C++ program for the above approach
5x
11
// C++ program for the above approach
5#include
9 using
14____416using
16
// C++ program for the above approach
5// C++ program for the above approach
4
using
1____520using
21 using
22
_______523____524____423
_______51____64____528
// C++ program for the above approach
19using
30____308#include
23
_______51____534
// C++ program for the above approach
5// and minima in the given array arr[]
2
________ 35 ________ 54
_______51____540____541 using
22
_______523____544____423
// C++ program for the above approach
5#include
9 using
48#include
16using
16
// C++ program for the above approach
5// C++ program for the above approach
4
using
1____520using
21 using
22
_______523____558____423
using
1____64using
62
// C++ program for the above approach
19using
30____308#include
23
_______51____534
// C++ program for the above approach
5// and minima in the given array arr[]
2
________ 35 ________ 54
using
1____540// C++ program for the above approach
18 using
22
using
23____578#include
23
// and minima in the given array arr[]
2
using
81
// C++ program for the above approach
86 // C++ program for the above approach
87 x
0 using
85
// C++ program for the above approach
4
// C++ program for the above approach
5// C++ program for the above approach
0 using
89using
90// C++ program for the above approach
00
// C++ program for the above approach
5// C++ program for the above approach
63
// C++ program for the above approach
5// C++ program for the above approach
0 using
96_______597using
98using
99using
98namespace
01using
98namespace
03using
98namespace
05using
98
// Function to find all the local maxima
7namespace
08using
98namespace
10using
98namespace
12using
98namespace
14 namespace
15
// C++ program for the above approach
5// C++ program for the above approach
70
// C++ program for the above approach
5// C++ program for the above approach
72
// and minima in the given array arr[]
2
// and minima in the given array arr[]
2
namespace
22
Python3
namespace
23
namespace
24
namespace
25
namespace
26 namespace
27
// C++ program for the above approach
5namespace
29
// C++ program for the above approach
5namespace
31
// C++ program for the above approach
5namespace
33namespace
34 namespace
35
// C++ program for the above approach
5namespace
37namespace
34 namespace
35
// C++ program for the above approach
5namespace
41
// C++ program for the above approach
5namespace
43
// C++ program for the above approach
5#include
9#include
15#include
16#include
17#include
18namespace
50
_______51____652____416using
16
// C++ program for the above approach
5namespace
56____415____416#include
29#include
18namespace
50
_______51____663____416using
16
// C++ program for the above approach
5namespace
67
// C++ program for the above approach
5namespace
69
// C++ program for the above approach
5namespace
4 namespace
72namespace
73 namespace
74namespace
5#include
18namespace
77namespace
78#include
18namespace
80
_______51____682
using
1#include
9namespace
85namespace
78#include
18namespace
88using
22 #include
18namespace
50
// C++ program for the above approach
19namespace
93
_______51____695
using
1namespace
56____685namespace
78#include
18std;
01____522 #include
18namespace
50
// C++ program for the above approach
19std;
06
// C++ program for the above approach
5std;
08
// C++ program for the above approach
5namespace
43
// C++ program for the above approach
5#include
9#include
15namespace
78#include
18#include
17namespace
78#include
90namespace
50
using
1std;
21____678#include
18using
16
// C++ program for the above approach
5namespace
56____415namespace
78#include
18#include
29namespace
78#include
90namespace
50
using
1____735namespace
78#include
18using
16
using
1std;
40
_______51____742
// C++ program for the above approach
5#include
9namespace
5std;
46std;
47#include
16namespace
80
using
1std;
51namespace
5std;
53std;
54
// C++ program for the above approach
19std;
56std;
57namespace
34std;
59
_______51____751____65____763std;
64
________ 35 ________ 54 ________ 767
_______51____751____65______771std;
54
// C++ program for the above approach
19std;
74using
16
// C++ program for the above approach
5#include
9namespace
5std;
46std;
80#include
16namespace
80
_______51std;
51____65____786std;
54
// C++ program for the above approach
19std;
56std;
57namespace
34std;
59
using
1std;
51____65______763std;
97
________ 35 ________ 54 ________ 767
_______51____751____65____804std;
54
// C++ program for the above approach
19// Function to find all the local maxima
07____516
// Function to find all the local maxima
09
#include
9 // Function to find all the local maxima
11namespace
34namespace
34 // Function to find all the local maxima
14std;
67
// C++ program for the above approach
5// Function to find all the local maxima
17namespace
34 using
90
// C++ program for the above approach
5// Function to find all the local maxima
21
// C++ program for the above approach
5// Function to find all the local maxima
23namespace
34 // Function to find all the local maxima
25using
97using
98using
99using
98namespace
01using
98namespace
03using
98namespace
05using
98namespace
08using
98namespace
10using
98namespace
12using
98namespace
14// Function to find all the local maxima
43