# A Multithreaded Algorithm for the Computation of Sample Entropy
## 1 Introduction  
Despite the rapid evolution of hardware technology, high-performance algorithms continue to pose significant challenges when it comes to achieving speed. Exploiting the capabilities of underlying hardware, reducing computational complexity, exploring novel algorithmic approaches and parallelizing computing tasks have all proven to be critical factors in high performance computing [1, 2]. Sample entropy [3, 4] is a definition of entropy which presents increased computational complexity and, therefore, slow execution times. Since the fast computation of sample entropy is crucial when a large amount of data is to be analyzed, we investigate parallel algorithms to achieve faster executions. Sample entropy has emerged as an improvement over approximate entropy [5], a similar measure of system complexity. They both assess the probability of a pattern in a time series being repeated at two consecutive scales, namely \(m\) and \(m+1\). A higher value of entropy indicates a more irregular or complex time series. Sample entropy finds its application in various fields, including biomedical signal analysis, financial time series analysis and seismographic data interpretation. For instance, in biomedical analysis, sample entropy has been employed to study the dynamics of physiological processes by examining the complexity and irregularity of heart rate variability [4, 6, 7]. It has also been used in several other fields of biomedical engineering, where it finds often application on EEG analysis, for example, in automatic epileptic seizuredetection [8], or in arrhythmia detection, for example, in paroxysmal atrial fibrillation detection [9], or even to analyze human postural sway data [10]. Financial time series analysis has also benefited from the use of sample entropy algorithms, enabling the assessment of system complexity and the detection of patterns in financial data [11]. Moreover, seismographic data analysis has utilized sample entropy to uncover correlations and variability in electrical signals related to earthquake activity, contributing to a deeper understanding of complex phenomena underlying seismic events [12]. Given the increasing volume of data being generated across various domains, efficient computation becomes crucial. To address this challenge, researchers have explored parallel algorithms to achieve faster execution times. Especially for sample entropy, slow execution times due to the inherent computational complexity can hinder the timely analysis of large data sets. Leveraging parallel computing techniques and utilizing the computational resources available in modern hardware architectures can significantly accelerate the computation of sample entropy, enabling the efficient analysis of large data sets within reasonable time frames. In our past research, we proposed two sequential fast algorithms for the rapid computation of sample entropy [13]. The first one, called the _bucket-assisted algorithm_, is still, to the best of our knowledge, the fastest way to compute sample entropy in the general case. In the special case, in which \(m=1\), the second algorithm proposed in the same paper, the _lightweight_ algorithm, presents lower execution times. Earlier, a fast algorithm for the computation of approximate entropy was also presented by our team [14]. In this paper, parallel approaches to the bucket-assisted algorithm are investigated. We focus on the multithreading technology, which is now supported by every processor (even the cost-effective ones used in our home computers). Multithreaded software becomes more and more important, and the development of libraries targeting high performance for cost-effective hardware emerges. A multithreaded Python library, based on underlying C code, implementing the fast, parallel algorithms examined here, is publicly available ([[https://cs.uoi.gr/~manis/entropy_threads/](https://cs.uoi.gr/~manis/entropy_threads/)]([https://cs.uoi.gr/~manis/entropy_threads/](https://cs.uoi.gr/~manis/entropy_threads/)), accessed on 2 June 2023).