Python tìm mảng 1D cực đại cục bộ

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

  1. Đặt một điểm đánh dấu trên đỉnh

  2. 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

  3. 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

  4. 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

  1. 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ộ
  2. 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[]
  3. 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
  4. 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[]

x0 x1// C++ program for the above approach0 // C++ program for the above approach1// C++ program for the above approach0 // C++ program for the above approach3

// C++ program for the above approach4

// C++ program for the above approach5

// C++ program for the above approach5// C++ program for the above approach7

// C++ program for the above approach5// C++ program for the above approach9

// C++ program for the above approach5#include 1____30#include 3

 

// C++ program for the above approach5#include 5

// C++ program for the above approach5#include 7

// C++ program for the above approach5#include 9 using0

using1using2

 

________ 35 ________ 54 ________ 49 ________ 56

using1using8

 

// C++ program for the above approach5namespace0

// C++ program for the above approach5namespace2

// C++ program for the above approach5namespace4namespace5// C++ program for the above approach0 namespace7

// C++ program for the above approach5// C++ program for the above approach4

using1

// C++ program for the above approach5std;2

// C++ program for the above approach5#include 9 std;5

using1std;7

using1std;9

using1

// C++ program for the above approach5// Function to find all the local maxima2

________ 35 ________ 54 ________ 49 ________ 86

// Function to find all the local maxima7// Function to find all the local maxima8

using1// and minima in the given array arr[]0

// C++ program for the above approach5// and minima in the given array arr[]2

 

// C++ program for the above approach5// and minima in the given array arr[]4

// C++ program for the above approach5#include 7

// C++ program for the above approach5#include 9 // and minima in the given array arr[]9

using1x01

 

________ 35 ________ 54 ________ 49 ________ 105

using1x07

 

// C++ program for the above approach5x09

// C++ program for the above approach5x11

// C++ program for the above approach5#include 9 x14

// C++ program for the above approach5// C++ program for the above approach4

using1x18x19// C++ program for the above approach00

using1namespace4namespace5// C++ program for the above approach0 // C++ program for the above approach05

using1// C++ program for the above approach07____308// C++ program for the above approach00

_______51____311

// C++ program for the above approach5// and minima in the given array arr[]2

________ 35 ________ 54

using1____118// C++ program for the above approach18

// C++ program for the above approach19// C++ program for the above approach20// C++ program for the above approach21// C++ program for the above approach00

 

// C++ program for the above approach5#include 9 // C++ program for the above approach25

// C++ program for the above approach5// C++ program for the above approach4

_______51____118____330// C++ program for the above approach00

using1____64____65// C++ program for the above approach0 // C++ program for the above approach36

using1// C++ program for the above approach07____308// C++ program for the above approach00

_______51____311

// C++ program for the above approach5// and minima in the given array arr[]2

________ 35 ________ 54

using1____118// C++ program for the above approach18

// C++ program for the above approach19// C++ program for the above approach20// C++ program for the above approach52// C++ program for the above approach00

// and minima in the given array arr[]2

 

// C++ program for the above approach55

// C++ program for the above approach0 // C++ program for the above approach57

// C++ program for the above approach4

// C++ program for the above approach5// C++ program for the above approach0 // C++ program for the above approach61

 

// C++ program for the above approach5// C++ program for the above approach63

// C++ program for the above approach5// C++ program for the above approach0 // C++ program for the above approach66

// Function to find all the local maxima7// C++ program for the above approach68

 

// C++ program for the above approach5// C++ program for the above approach70

// C++ program for the above approach5// C++ program for the above approach72

// C++ program for the above approach5// C++ program for the above approach74 // C++ program for the above approach75

// and minima in the given array arr[]2

 

// C++ program for the above approach77

Java




// C++ program for the above approach78

// C++ program for the above approach79 // C++ program for the above approach80

// C++ program for the above approach81 // C++ program for the above approach82

// C++ program for the above approach5

________số 8

// and minima in the given array arr[]

________ 386 ________ 387 ________ 10 x1// C++ program for the above approach0 // C++ program for the above approach1

// C++ program for the above approach92____30// C++ program for the above approach94

// C++ program for the above approach4

// C++ program for the above approach5

// C++ program for the above approach5// C++ program for the above approach7

// C++ program for the above approach5// C++ program for the above approach9

// C++ program for the above approach5#include 02____403 #include 04

// C++ program for the above approach5#include 06#include 03 #include 04

 

// C++ program for the above approach5#include 5

// C++ program for the above approach5#include 7

// C++ program for the above approach5#include 9 #include 15#include 16#include 17#include 18#include 19

_______51____421____416#include 23

 

// C++ program for the above approach5using4 #include 9 #include 15#include 16#include 29#include 18#include 19

_______51____433____416#include 23

 

// C++ program for the above approach5namespace0

// C++ program for the above approach5namespace2

// C++ program for the above approach5namespace4namespace5// C++ program for the above approach0 #include 44#include 18#include 46#include 18#include 48

// C++ program for the above approach5// C++ program for the above approach4

using1std;2

using1#include 9 #include 55#include 18#include 57

// C++ program for the above approach19#include 59____418#include 61

// C++ program for the above approach19#include 63

// C++ program for the above approach19

using1// Function to find all the local maxima2

using1using4 #include 9 #include 55#include 18#include 72

_______87____474____418#include 61

// C++ program for the above approach19#include 78

// C++ program for the above approach5// and minima in the given array arr[]2

 

// C++ program for the above approach5// and minima in the given array arr[]4

// C++ program for the above approach5#include 7

// C++ program for the above approach5#include 9 #include 87#include 18#include 89#include 90#include 19

using1____493____418#include 23

 

// C++ program for the above approach5using4 #include 9 #include 87____418using01#include 90#include 19

using1____505____418#include 23

 

// C++ program for the above approach5x09

// C++ program for the above approach5x11

// C++ program for the above approach5#include 9 using14____416using16

// C++ program for the above approach5// C++ program for the above approach4

using1____520using21 using22

_______523____524____423

_______51____64____528

// C++ program for the above approach19using30____308#include 23

_______51____534

// C++ program for the above approach5// and minima in the given array arr[]2

________ 35 ________ 54

_______51____540____541 using22

_______523____544____423

 

// C++ program for the above approach5#include 9 using48#include 16using16

// C++ program for the above approach5// C++ program for the above approach4

using1____520using21 using22

_______523____558____423

using1____64using62

// C++ program for the above approach19using30____308#include 23

_______51____534

// C++ program for the above approach5// and minima in the given array arr[]2

________ 35 ________ 54

using1____540// C++ program for the above approach18 using22

using23____578#include 23

// and minima in the given array arr[]2

 

using81

// C++ program for the above approach86 // C++ program for the above approach87 x0 using85

// C++ program for the above approach4

// C++ program for the above approach5// C++ program for the above approach0 using89using90// C++ program for the above approach00

 

// C++ program for the above approach5// C++ program for the above approach63

// C++ program for the above approach5// C++ program for the above approach0 using96_______597using98using99using98namespace01using98namespace03using98namespace05using98

// Function to find all the local maxima7namespace08using98namespace10using98namespace12using98namespace14 namespace15

 

// C++ program for the above approach5// C++ program for the above approach70

// C++ program for the above approach5// C++ program for the above approach72

// and minima in the given array arr[]2

// and minima in the given array arr[]2

 

namespace22

Python3




namespace23

 

namespace24

namespace25

 

namespace26 namespace27

 

// C++ program for the above approach5namespace29

// C++ program for the above approach5namespace31

// C++ program for the above approach5namespace33namespace34 namespace35

// C++ program for the above approach5namespace37namespace34 namespace35

 

// C++ program for the above approach5namespace41

// C++ program for the above approach5namespace43

// C++ program for the above approach5#include 9#include 15#include 16#include 17#include 18namespace50

_______51____652____416using16

// C++ program for the above approach5namespace56____415____416#include 29#include 18namespace50

_______51____663____416using16

 

// C++ program for the above approach5namespace67

// C++ program for the above approach5namespace69

// C++ program for the above approach5namespace4 namespace72namespace73 namespace74namespace5#include 18namespace77namespace78#include 18namespace80

 

_______51____682

using1#include 9namespace85namespace78#include 18namespace88using22 #include 18namespace50

// C++ program for the above approach19namespace93

 

_______51____695

using1namespace56____685namespace78#include 18std;01____522 #include 18namespace50

// C++ program for the above approach19std;06

 

// C++ program for the above approach5std;08

// C++ program for the above approach5namespace43

// C++ program for the above approach5#include 9#include 15namespace78#include 18#include 17namespace78#include 90namespace50

using1std;21____678#include 18using16

// C++ program for the above approach5namespace56____415namespace78#include 18#include 29namespace78#include 90namespace50

using1____735namespace78#include 18using16

 

using1std;40

_______51____742

// C++ program for the above approach5#include 9namespace5std;46std;47#include 16namespace80

using1std;51namespace5std;53std;54

// C++ program for the above approach19std;56std;57namespace34std;59

_______51____751____65____763std;64

________ 35 ________ 54 ________ 767

_______51____751____65______771std;54

// C++ program for the above approach19std;74using16

 

// C++ program for the above approach5#include 9namespace5std;46std;80#include 16namespace80

_______51std;51____65____786std;54

// C++ program for the above approach19std;56std;57namespace34std;59

using1std;51____65______763std;97

________ 35 ________ 54 ________ 767

_______51____751____65____804std;54

// C++ program for the above approach19// Function to find all the local maxima07____516

 

// Function to find all the local maxima09

#include 9 // Function to find all the local maxima11namespace34namespace34 // Function to find all the local maxima14std;67

 

// C++ program for the above approach5// Function to find all the local maxima17namespace34 using90

// C++ program for the above approach5// Function to find all the local maxima21

// C++ program for the above approach5// Function to find all the local maxima23namespace34 // Function to find all the local maxima25using97using98using99using98namespace01using98namespace03using98namespace05using98namespace08using98namespace10using98namespace12using98namespace14// Function to find all the local maxima43

Chủ Đề