Skip to main content
. 2026 Sep 9;26(18):5741. doi: 10.3390/s26185741
Algorithm A1. Information entropy calculation
Input: Time series data X = [x1, x2, …, xN], Number of bins B
Output: Information entropy value H
1. Initialize:
     Calculate min_val = min(X)
     Calculate max_val = max(X)
     Calculate bin_width = (max_val − min_val)/B
2. Create bins and count:
     Initialize counts [1..B] = 0
     FOR i = 1 TO N:
              bin_index = FLOOR((X[i] − min_val)/bin_width) + 1
              IF bin_index > B:
                    bin_index = B
              END IF
              counts[bin_index] = counts[bin_index] + 1
        END FOR
3. Calculate probability distribution:
     FOR i = 1 TO B:
              prob[i] = counts[i]/N
        END FOR
4. Calculate information entropy:
     H = 0
     FOR i = 1 TO B:
              IF prob[i] > 0:
                    H = H − prob[i] * log2(prob[i])
              END IF
        END FOR
5. RETURN H