In this section, we introduce the MCSampEn2D and UCBMCSampEn2D algorithms. Before delving into the details of these approaches, we will first establish the key mathematical symbols and fundamental concepts integral to understanding MCSampEn2D. This groundwork provides a clear and comprehensive exposition of both the MCSampEn2D and UCBMCSampEn2D algorithms.
2.1. Groundwork of Two-Dimensional Sample Entropy
Let
be an image of size
. For all
and
, define two-dimensional matrices
with size
, named template matrices, by
where
is the embedding dimension vector [
20]. We also define
. For all
and
, let
be the greatest element of the absolute differences between
and
. We denote by
the cardinality of a set
E. Then, for fixed
k and
l, we count
, and compute
where
r is the predefined threshold (tolerance factor). We also define
as
Finally,
is defined as follows [
20]:
where
. The parameter
indicates the size of the matrices, which are analyzed or compared along images. In this study, [
20,
21],
is chosen to obtain squared template matrices, and let
. For all
, we denote
. The process for computing
is summarized in Algorithm 1.
The parameter
r is selected to strike a balance between the quality of the logarithmic likelihood estimates and the potential loss of signals or image information. If
r is chosen to be too small (less than 0.1 of the standard deviation of an image), it leads to poor conditional probability estimates. Additionally, to mitigate the influence of noise on the data, it is advisable to opt for a larger
r. Conversely, when
r exceeds 0.4 of the standard deviation, excessive loss of detailed data information occurs. Therefore, a trade-off between large and small
r values is essential. For a more in-depth discussion on the impact of these parameters in
, please refer to [
20].
Algorithm 1 Two-dimensional sample entropy |
Require: Sequence, template lengthm and thresholdr.
- 1:
procedure SampEn2D() - 2:
Set, - 3:
Set, - 4:
for to do - 5:
for to do - 6:
;, - 7:
, - 8:
, - 9:
if then - 10:
, - 11:
return
|
2.2. A Monte Carlo-Based Algorithm for Estimating Two-Dimensional Sample Entropy
The SampEn is fundamentally defined as
, where
B represents the number of matching template pairs of length
m, and
A represents the number of matching template pairs of length
. The most computationally intensive step in calculating SampEn involves determining the ratio
for templates of lengths
m and
. Notably,
(resp.
) denotes the probability of template matches of length
m (resp.
), and the ratio
can be interpreted as a conditional probability. The statement indicates that the computation time of the MCSampEn method becomes independent of the data size and, instead, depends on the number of sampling points
and the number of repetitions
. This complexity is denoted as
[
17].
The objective of the MCSampEn algorithm [
17] is to approximate this conditional probability for the original dataset by considering the conditional probability of a randomly subsampled dataset. Specifically, the MCSampEn randomly selects
templates of length
m and
templates of length
from the original time series. It subsequently computes the number of matching pairs in the selected templates of length
m (resp.
), denoted as
(resp.
). This selection process is repeated
times, and the average value of
(resp.
), represented as
(resp.
), is then calculated. Finally,
is employed to approximate the complexity measurement
for the time series. The entire process can be expressed succinctly using the following formula:
where
(resp.
) means the number of matching pairs in the selected templates of length
m (resp.
) in in the
k-th experiment.
When extending the MCSampEn algorithm to process two-dimensional data, a random sampling step is essential at the outset to acquire
N data points. The technique employs a specific sampling strategy to sample
positive integer sets, denoted as
and
. Subsequently, for each
, compute
and
, which indicates a two-dimensional matrix
. Then, we randomly select
templates of size
and
templates of length
from the original two-dimensional data. It subsequently computes the number of matching pairs, with tolerant factor
r, in the selected templates of length
(resp.
), denoted as
(resp.
). This selection process is repeated
times, and the average value, represented as
(resp.
), is then calculated. Replacing
and
by
and
in (
5), respectively, we obtain an approximation of
. This process is summarized in Algorithm 2, which calls Algorithm 1.
Algorithm 2 Two-dimensional Monte Carlo sample entropy (MCSampEn2D) |
Require: Sequence, template lengthm, thresholdr, Sample numbers and experimental rounds.
- 1:
procedure MCSampEn2D() - 2:
Set and, - 3:
for to do - 4:
Set where and are selected on pixel coordinates with uniform distribution, - 5:
Compute by calling SampEn2D(), - 6:
Compute by calling SampEn2D(), - 7:
, - 8:
- 9:
, - 10:
return
|
It is easy to check the computational cost of MCSampEn2D is
when
is fixed. Through a proof process similar to that of Theorem 5 in [
17], we can see that the output of MCSampEn2D,
, is approximating the output of SampEn2D with the rate
in the sense of almost sure convergence when
is fixed. Furthermore, in our examination of MCSampEn2D, we observed variability in the significance of the randomly subsampled dataset. This is manifested as large fluctuations in the errors between the values of
(or
) obtained in each of the
rounds of experiments and their respective average values,
(or
). Such fluctuations amplify the errors in the output of MCSampEn2D. This phenomenon made us realize that if we could capture the importance of different experimental rounds and use this importance to calculate a weighted average of
(or
) obtained in the
rounds of experiments, we could achieve a faster algorithm than MCSampEn2D.
2.3. Monte Carlo Sample Entropy Based on the UCB Strategy
The UCB strategy is a refinement in the field of optimization, particularly tailored for the intricate problem of the multi-armed bandit. This problem, often conceptualized as a machine or ’gambler’ with multiple levers (or ’arms’), each offering random rewards on each interaction, demands finding the optimal lever that maximizes reward yield with minimal experimentation. The UCB strategy’s core principle is to meticulously balance the pursuit of exploration and exploitation. Exploration, in this context, signifies the willingness to experiment with untested options, while exploitation underscores the preference to capitalize on the rewards offered by gamblers with a proven track record of high performance. This balancing act, inherent in the UCB strategy, aids in optimizing the overall reward yield by efficiently determining the optimal balance between exploring new options and exploiting known high-reward choices, thereby minimizing the number of trials required to reach the optimal solution [
22,
23].
In the preceding section, we presented the MCSampEn2D for estimating two-dimensional sample entropy. The precision of MCSampEn2D is contingent upon factors such as the number of experimental rounds, denoted as
, the quantity of sampled points,
, and the representativeness of these sampled points. Given that distinct experimental rounds involve the selection of different sampled points, their representativeness inherently varies. In Equation (
5), the weight assigned to each round is statically set to
. To enhance accuracy, we can dynamically adjust the weights based on the representativeness of the sampled points in each round.
The adjustment of weights based on the representativeness of the sampled points serves to refine the estimation of sample entropy in each round, thereby enhancing the overall precision of the algorithm. This approach aims to ensure that the sampling process more accurately reflects the inherent characteristics of the dataset.
In the realm of decision-making under limited resources, the multi-armed bandit problem represents a classic challenge in reinforcement learning, involving a series of choices with the goal of maximizing cumulative rewards. The UCB strategy emerges as a crucial approach for tackling the multi-armed bandit problem. Its central concept revolves around dynamically assessing the potential value of each choice [
24,
25], seeking a balance between the exploration of unknown options and the exploitation of known ones.
At the core of the UCB strategy is the principle of making selections based on the upper confidence bounds. In this strategy, each arm represents a potential choice, and the true reward value of each arm remains unknown. In Algorithm 2, we refer to the process executed from step 5 to step 6 as one epoch. Under the UCB strategy, we conceptualize each epoch as an arm, which means that epochs represent arms, and dynamically update its upper confidence bound based on a designated reward function for each epoch. The UCB strategy involves the following three steps at each time step.
Firstly, the average reward for each round of epochs is calculated by
where
signifies the average reward for the
i-th round. In our design, each epoch is utilized only once per round, thus we set
for all
. Here,
represents the reward for the current epoch, estimated from historical data.
To design
, we define the following notations. For all
, let
be the average of the sample entropy of the preceding
rounds,
, be the entropy computed for the ongoing round, and
, where
. Considering that different images inherently possess distinct entropies, we introduce the error ratio
to characterize the error situation for the
i-th round. This ratio is then used as an input to the reward function
. In formulating the reward function, our objective is to assign higher rewards to rounds where errors are closer to 0. Multiple choices exist for defining the reward function
R, provided that it aligns with the design specifications of the particular scenario. Various mathematical functions, such as the cosine function and normal distribution function, among others, are viable options for constructing the reward function. The selection of a specific function is contingent upon its ability to meet the desired criteria and effectively capture the intended behavior in the context of the given problem. Then, we set the average reward
for the
i-th round of epochs formula as
where
a is a scaling factor for the reward and
b controls the scale of
.
Secondly, we calculate the upper confidence limit boundary for each round of epochs by
where
represents the upper confidence bound for the
i-th round and set
as a constant equal to 1, we use a parameter
c to control the degree of exploration. Denote
, which is the set of UCB.
Thirdly, for the set
, we employ the softmax function to determine the proportional weight each epoch round should have, thereby replacing the average proportion used in MCSampEn2D. We then calculate
and
for the UCBMCSampEn2D by
where
and the UCBMCSampEn can be calculated by
The pseudocode for the entire UCBMCSampEn is outlined in Algorithm 3.
Algorithm 3 Monte Carlo sample entropy based on UCB strategy |
Require: Sequence, template lengthm, thresholdr,
Sample numbers and epoch numbers. - 1:
procedure UCBMCSampEn() - 2:
Set and, - 3:
for to do - 4:
Set where and are selected on pixel coordinates with uniform distribution, - 5:
Compute by calling SampEn2D(), - 6:
Compute by calling SampEn2D(), - 7:
Compute,, - 8:
Compute, - 9:
Compute, - 10:
Set, - 11:
Set, - 12:
for to do - 13:
, - 14:
,
- 15:
return
|
Because the averaging strategy in the MCSampEn method does not consider the varying importance of sampling points across different epochs, it can result in significant errors. Although the UCB strategy introduces bias [
26], it can mitigate the errors introduced by the averaging strategy, transforming the uniform strategy in the original method into an importance-based strategy. This adjustment aligns the sampling more closely with the actual characteristics of the data.