{'fraction_non_alphanumeric': 0.041009778487327876, 'fraction_numerical': 0.011142153928025011, 'mean_word_length': 4.328194222931065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Entropy of finite random binary sequences with weak long-range correlations

We study the N-step binary stationary ergodic Markov chain and analyze its differential entropy. Supposing that the correlations are weak we express the conditional probability function of the chain through the pair correlation function and represent the entropy as a functional of the pair correlator. Since the model uses the two-point correlators instead of the block probability, it makes it possible to calculate the entropy of strings at much longer distances than using standard methods. A fluctuation contribution to the entropy due to finiteness of random chains is examined. This contribution can be of the same order as its regular part even at the relatively short lengths of subsequences. A self-similar structure of entropy with respect to the decimation transformations is revealed for some specific forms of the pair correlation function. Application of the theory to the DNA sequence of the R3 chromosome of Drosophila melanogaster is presented.


I. INTRODUCTION
At present there is a commonly accepted viewpoint that our world is complex and correlated. The most peculiar manifestations of this concept are the records of brain activity and heart beats, human and animal communication, written texts of natural languages, DNA and protein sequences, data flows in computer networks, stock indexes, sun activity, weather (the chaotic nature of the atmosphere), etc. For this reason systems with longrange interactions (and/or with long-range memory) and natural sequences with non-trivial information content have been the focus of a large number of studies in different fields of science over the past several decades.
Random sequences with finite number of states exist as natural sequences (DNA or natural texts) or arise as a result of coarse-grained mapping of the evolution of the chaotic dynamic system into a string of symbols [1,2]. Such sequences are very closely connected to and are the subject of study of the algorithmic (Kolmogorov-Solomonoff-Chaitin) complexity, artificial intellect, information theory, compressibility of digital data, statistical inference problem, computability [3] and have many application aspects as a creative tool for designing the devices and appliances with random components in their structure [4] (different wave-filters, diffraction gratings, artificial materials, antennas, converters, delay lines, etc.).
There are many methods for describing complex dynamical systems and random sequences connected with them: correlation function, fractal dimensions, multipoint probability distribution functions, and many others. One of the most convenient characteristics serving to the purpose of studying complex dynamics is entropy [3,5]. Being a measure of the information content and redundancy in a sequence of data, it is a powerful and popular tool in examination of complexity phenomena. It has been used for the analysis of a number of different dynamical systems.
A standard method of understanding and describing statistical properties of real physical systems or random sequences of data can be represented as follows. First of all, we have to analyze the sequence to find the correlation functions or the probabilities of words occurring, with the length L exceeding the correlation length R c but being shorter than the length M of the sequence, At the same time, the number d L of different words of the length L composed in the alphabet containing d letters has to be much less than the number M − L of words in the sequence, The next step is to express the correlation properties of the sequence in terms of the conditional probability function (CPF) of the Markov chain, see below Eq. (5). Note, the Markov chain should be of order N , which is supposed to be longer than the correlation length, This is the critical requirement because the correlation length of natural sequence of interest (e.g., written or DNA texts) is usually of the same order as the length of sequences. None of inequalities (1) − (3) can be fulfilled. Really, the lengths of words that could represent correctly the probability of words occurring are 4 − 5 letters for a real natural text of the length 10 6 (written on an alphabet containing 27 − 30 letters and symbols) or of order of 20 symbols for a coarse-grained text represented by means of a binary sequence.
Here we develop an approach that is complimentary to the above exposed. In particular, we represent the conditional probability function of the Markov chain by means of pair correlator, which makes it possible to calculate analytically the entropy of the sequence. It should be stressed that the standard method for calculating the entropy can only take into account the short-range part of statistics. We present a theory that expresses long-range correlation properties through the correlation functions.
The scope of the paper is as follows. First, we discuss briefly the properties of the N -step additive Markov chain model and, supposing that the correlations between symbols in the sequence are weak, we express the conditional probability function by means of the pair correlation function. In the next section we represent the differential entropy in terms of the conditional probability function of the Markov chain and express the entropy as the sum of squares of the pair correlators. Then we discuss some properties of the results obtained, in particular, a property of self-similarity of entropy with respect to decimation for some particular classes of the Markov chains. Next, a fluctuation contribution to the entropy due to finiteness of random chains is examined. Some remarks on literary texts are followed by discussions of directions in which the research can be progressed.
Consider a semi-infinite sequence A = a ∞ 0 = a 0 , a 1 , a 2 , ... of real random variables a i taken from the finite alphabet A = {1, 2, ..., d}, a i ∈ A. The sequence A is an N -step Markov chain if it possesses the following property: the probability of symbol a i to have a certain value a under the condition that the values of all other symbols are given depends only on the values of N previous symbols, Note, definition (4) is valid for i ≥ N ; for i < N we have to use the well known conditions of compatibility for the conditional probability functions of the lower order, Ref. [6]. Sometimes the number N is also referred to as the order or the memory length of the Markov chain. The conditional probability function (CPF) P (a i = a|a i−N , . . . , a i−2 , a i−1 ) determines completely all statistical properties of the Markov chain and the method of their iterative numerical construction. If the sequence, statistical properties of which we would like to analyze is assigned, the conditional probability function of the N -th order can be found by a standard method, P (a N +1 = a|a 1 , . . . , a N ) = P (a 1 , . . . , a N , a) P (a 1 , . . . , a N ) , where P (a 1 , . . . , a N ) is the probability of the N -words a 1 , . . . , a N occurring. The Markov chain determined by Eq. (4) is a homogeneous sequence because its conditional probability does not depend explicitly on i, i.e., is independent of the position of symbols a i−N , . . . , a i−1 , a i in the chain. It depends only on the values of symbols a i−N , . . . , a i−1 , a i . The homogeneous sequences are stationary: the average value of any function f (a r1 , a r1+r2 , . . . , a r1+...+rs ) of s arguments f (a r1 , . . . , a r1+...+rs ) = lim f (a i+r1 , . . . , a i+r1+...+rs ) depends on s − 1 differences between the indexes. In other words, all statistically averaged functions of random variables are shift-invariant.
We suppose that the chain is ergodic. According to the Markov theorem (see, e.g., Ref. [6]), this property is valid for the homogenous Markov chains if the strict inequalities, are fulfilled for all possible values of the arguments in function (4). Hereafter we use the shorter notation a i−1 i−N for N -word a i−N , ..., a i−1 . It follows from ergodicity that the correlations between any blocks of symbols in the chain go to zero when the distance between them goes to infinity. The other consequence of ergodicity is the possibility to use one random sequence as an equitable representative of the ensemble of chains and to do averaging over the sequence, Eq. (6), instead of an ensemble averaging.
Below we will consider an important class of the binary random sequences with symbols a i taking on two values, say 0 and 1, a i ∈ {0, 1}. The conditional probability to find i-th element a i = 1 in the binary N -step Markov sequence depending on N preceding elements a i−1 i−N is a set of 2 N numbers: Conditional probability (8) of the binary sequence of random variables a i ∈ {0, 1} can be represented exactly as a finite polynomial series: where the statistical averages a r1 . . . a rN are taken over sequence (6), F s is the family of memory functions andā is the relative average number of unities in the sequence. The representation of Eq. (8) in the form of Eq. (9) follows from the simple identical equalities, a 2 = a and f (a) = af (1) + (1 − a)f (0), for an arbitrary function f (a) determined on the set a ∈ {0, 1}. The first term in Eq. (9) is responsible for generation of uncorrelated white-noise sequences. Taking into account the second term, proportional to F 1 (r), we can reproduce correctly correlation properties of the chain up to the second order. Higher-order correlators and all correlation properties of higher orders are not independent anymore. We cannot control them and reproduce correctly by means of the memory function F (r), because the latter is completely determined by the pair correlation function, see below Eq. (11). Studying of the properties of these higherorder correlators is beyond the scope of this paper. In what follows we will only use the first two terms, which determine the so-called additive Markov chain [7,8].
A particular form of the conditional probability function of additive Markov chain is the chain with step-wise memory function, The probability P (1|k) of having the symbol a i = 1 after There is a rather simple relation between the memory function F (r) (hereafter we will omit the subscript 1 of F 1 (r)) and the pair correlation function of the binary additive Markov chain. There were suggested two methods for finding the F (r) of a sequence with a known pair correlation function. The first one [7] is based on the minimization of a "distance" between the Markov chain generated by means of the sought-for memory function and the initial given sequence of symbols with a known correlation function. The minimization equation yields the relationship between the correlation and memory functions, where the normalized correlation function K(r) is given by The second method for deriving Eq. (11) is the completely probabilistic straightforward calculation [9]. Equation (11), despite its simplicity, can be analytically solved only in some particular cases: for one-or two-step chains, Markov chain with step-wise memory function and so on. To avoid the difficulties in solving Eq. (11) we suppose that correlations in the sequence are weak. This means that all components of the normalized correlation function are small, |K(r)| ≪ 1, |r| = 0, with the exception of K(0) = 1. So, taking into account that in the sum of Eq. (11) the leading term is K(0) = 1 and all the others are small, we can obtain an approximate solution for the memory function in the form of the series The equation for the conditional probability function in the first approximation with respect to the small functions |K(r)| ≪ 1, |r| = 0 takes the form This formula provides a very important tool for constructing a sequence with a given pair correlation function. Note that i-independence of the function P (1|a i−1 i−N ) guarantees homogeneity and stationarity of the sequence under consideration; and finiteness of N provides its ergodicity. Evidently, we can only consider sequences with the correlation functions, determined by P (1|a i−1 i−N ), which satisfy Eq. (7).
The correlation functions are typically employed as the input characteristics for describing the random sequences. However, the correlation function describes not only the direct interconnection of the elements a i and a i+r , but also takes into account their indirect interaction via all other intermediate elements. Our approach operates with the "origin" characteristics of the system, specifically, with the memory function. The correlation and memory functions are mutually complementary characteristics of a random sequence in the following sense. The numerical analysis of a given random sequence enables one to determine directly the correlation function rather than the memory function. On the other hand, it is possible to construct a random sequence using the memory function, but not the correlation one, in the general case. Therefore, the memory function permits one to get a deeper insight into the intrinsic properties of the correlated systems. Equation (14) shows that in the limit of weak correlations both functions play the same role.
The concept of the additive Markov chain was extensively used earlier for studying random sequences with long-range correlations. The examples and references can be found in Ref. [8].

III. DIFFERENTIAL ENTROPY
In order to estimate the entropy of an infinite stationary sequence A of symbols a i one could use the block entropy, Here P (a L 1 ) = P (a 1 , . . . , a L ) is the probability to find the L-word a L 1 in the sequence. The differential entropy, or entropy per symbol, is given by and specifies the degree of uncertainty of the (L + 1)th symbols observing if the preceding L symbols are known. The source entropy (or Shannon entropy) is the differential entropy at the asymptotic limit, h = lim L→∞ h L . This quantity measures the average information per symbol if all correlations, in the statistical sense, are taken into account. The differential entropy h L can be presented in terms of the conditional probability function. To show this we have to rewrite Eq. (15) for the block of length L + 1, express P (a L+1 1 ) via the conditional probability, and after a bit of algebra we obtain Here h(a L+1 |a L 1 ) is the amount of information contained in the (L + 1)-th symbol of the sequence conditioned on L previous symbols, So, the differential entropy h L of random sequence is presented as a special case of the standard conditional entropy H = − C P (C) B P (B|C) log 2 P (B|C). The conditional probability P (1|a i−1 i−L ) at L < N , is obtained in the first approximation in the parameter δ from Eq. (14) by means of the probabilistic reasoning presented in the Appendix. Taking into account the weakness of correlations, |δ| ≪ min[a, (1 − a)], one can expand the right-hand side of Eq. (18) in Taylor series up to the second order in δ, h(a L+1 |a L 1 ) = h 0 + (∂h/∂a) |δ=0 δ + (1/2)(∂ 2 h/∂a 2 ) |δ=0 δ 2 , where the derivatives are taken at the "equilibrium point" P (1|a i−1 i−L ) =ā and h 0 is the entropy of uncorrelated sequence, Upon using Eq. (17) for averaging h(a L+1 |a L 1 ) and in view of δ = 0, the differential entropy of the sequence becomes If the length of block exceeds the memory length, L > N , the conditional probability P (1|a i−1 i−L ) depends only on N previous symbols, see Eq. (4). Then, it is easy to show from (17) that the differential entropy remains constant at L ≥ N . The second line of Eq. (21) is consistent with the first one because in the first approximation in δ the correlation function vanishes at L > N together with the memory function. The final expression, the main result of the paper, for the differential entropy of the stationary ergodic binary weakly correlated random sequence is

IV. DISCUSSION
It follows from Eq. (22) that the additional correction to the entropy h 0 of the uncorrelated sequence is the negative and monotonously decreasing function of L. This is the anticipated result -the correlations decrease the entropy. The conclusion is not sensitive to the sign of correlations: persistent correlations, K > 0, describing an "attraction" of the symbols of the same kind, and anti-persistent correlations, K < 0, corresponding to an attraction between "0" and "1", provide the corrections of the same negative sign. If the correlation function is constant at 1 r N , the entropy is a linear decreasing function of the argument L up to the point N ; the result is coincident with that obtained in Ref. [14] (in the limit of weak correlations) for the Markov chain model with step-wise memory function (10).
As an illustration of result (22), in Fig. 1 we present the plot of the differential entropy versus the length L. Both numerical and analytical results (the dotted and solid curves) are presented for the power-law correlation function K(r) = 0.01/r 1.1 . The cut-off parameter r c of the power-law function for numerical generation of the sequence, coinciding with the memory length of the chain, is 10 4 . The good agreement between the curves is the manifestation of adequateness of the additive Markov chain approach for studying entropy properties of random chains. The abrupt deviation of the dashed line from the upper analytical and numerical curves at L ∼ 10 is the result of violation of inequality (2) and a manifestation of quickly growing errors in the entropy estimation by using the probability P (a 1 , . . . , a L ) of the L blocks occurring. Note that violation of Eq.(2) does not depend on the choice of the model parameter. It only depends on the length M of the random sequence.
In the main panel of Fig. 1 the deviation of numerical curve from analytical one is nearly absent. Nevertheless  (14) and the numerically evaluated correlation function K(r) of the constructed sequence. The dashed line is the differential entropy, Eqs. (15) and (16), plotted by using the numerical estimation of probability P (a1, . . . , aL) of the L-blocks occurring in the same sequence. The inset demonstrate the linear dependence of differential entropy at large L governed by fluctuations of the correlation function.
in the large scale, presented in the inset, a systematic linear deviation of numerical result from the analytical one is clearly seen. Explication of this phenomenon is given in the next section while discussing finite random sequences. Our next illustration of applicability of the developed theory deals with the DNA sequence of the R3 chromosome of Drosophila melanogaster. In Fig. 2 the plot of the differential entropy versus the length L is presented. We see that coincidence of the two approaches only holds for L 5 − 6 units. It is difficult to do a single-valued conclusion of which factor, finiteness of the chain and violation of Eq. (2) or strength of correlations, is more important for discrepancy between two theories. Nevertheless, even observed coincidence between two curves seems rather astonishing.
Markov's chains with step-wise memory functions and a larger class of permutable chains are invariant under decimation procedure [11]. Chains whose conditional probability functions are independent of the order of symbols in the N word preceding a generated symbol are referred to as permutable. The decimation is a reduction of a random sequence by regular or random removing some part of symbols from the whole chain. It was shown in Refs. [10,11] that after decimation the correlation function of indicated classes of sequences is invariant up to the new reduced memory length N * = λN , where λ is the relative non removed part of symbols in the chain. Hence, after decimation Eq. (21) does not change its form, but instead of N we have only to put the new memory length N * . The solid line is obtained by using Eq. (22) with numerically evaluated correlation function Eq. (12). The dashed line is the differential entropy, Eqs. (15) and (16), plotted by using the numerical estimation of probability P (a1, . . . , aL) of the L blocks occurring in the same sequence.

V. FINITE RANDOM SEQUENCES
The relative average number of unitiesā, correlation functions and other statistical characteristics of random sequences are deterministic quantities only in the limit of their infinite lengths. It is the direct consequence of the law of large numbers. If the length M of the sequence is finite, the set of numbers a M 1 cannot be considered anymore as ergodic sequence. In order to restore its status we have to introduce an ensemble of finite sequences {a M 1 } p , p ∈ N = 0, 1, 2, .... However, we would like to retain the right to examine finite sequences even if approximately by using a single finite chain. So, for a finite chain we have to replace definition (12) of the correlation function by the following one, Now the correlation functions andā are random quantities depending on a particular realization of the sequence a M 1 . Their fluctuations can contribute to the entropy of finite random chains even if the correlations in the random sequence are absent. It is well known that the order of relative fluctuations of additive random quantity (as, e.g. the correlation function Eq. (23)) is 1/ √ M . Below we give more rigorous justification of this explanation and show its applicability to our case. Let us present the correlation function C M (r) as the sum of two components, where the first summand C(r) = lim M→∞ C M (r) is the correlation function determined by Eqs. (12) and (23), obtained by averaging over the sequence with respect to the index i, numbering the elements a i of the sequence A; and the second one, C f (r), is a fluctuation-dependent contribution. The function C(r) can be also presented as the ensemble average C(r) = C M (r) due to ergodicity of the sequence. Now we can find a connection between variances of C M (r) and C f (r). Taking into account that the correlations are weak and neglecting their contribution into C f (r) we have In order to obtain the last equation we used Eq. (24) and the property of the function C f (r) = 0 at r = 0. The mean fluctuation of the squared correlation function Neglecting correlations between the elements a n and taking into account that only the terms with n = m give nonzero contribution into the result we easily obtain Note that Eq. (27) is obtained by means of averaging over the ensemble of chains. This is the shortest way to obtain the desired result. At the same time, for numerical simulations we used only averaging over the chain as is seen from Eq. (23), where summation over the sites i of the chain plays the role of averaging.
Note also that different symbols a i in Eq. (26) are correlated. It is possible to show that contribution of their correlations to K 2 f (r) is of order R c /M 2 ≪ 1/M . The fluctuating part of entropy, proportional to L r=1 K 2 f (r), should be subtracted from Eq. (22), which is only valid for the infinite chain. Thus, Eqs. (25) and (27) yield the differential entropy of the finite binary weakly correlated random sequences It is clear that in the limit M → ∞ this function transforms into Eq. (22). When L ≪ M the last term in Eq. (28) takes the form L/M and describes the linear decreasing entropy in the inset of Fig. 1.
The squared correlation function K 2 M (r) is usually a decreasing function of r, whereas the function K 2 f (r) is an increasing one. Hence, the terms L r=1 K 2 M (r) and log 2 [M/(M − L] being concave and convex functions describe competitive contributions to the entropy. It is not possible to analyze all particular cases of their relationship. Therefore we indicate here the most interesting ones keeping in mind a monotonically decreasing correlation function. An example of such type of function, K(r) = a/r b , a > 0, b 1, was considered above.
If the correlations are extremely small and compared with the inverse length M of the sequence, K 2 M (1) ∼ 1/M , the fluctuating part of entropy exceeds the correlation one nearly for all values of L > 1. With increasing of M (or correlations), when the inequality K 2 M (1) > 1/M is fulfilled, there is at list one point where the contribution of fluctuation and correlation parts of entropy are equal. For monotonically decreasing function K(r) there is only one such point. Comparing the functions in square brackets in Eqs. (28) we find that they are equal at some L = R s , which hereafter will be referred to as a stationarity length. If L ≪ R s , the fluctuations of the correlation function are negligibly small with respect to its magnitude, hence the finite sequence may be considered as quasi-stationary. At L ∼ R s the fluctuations are of the same order as the genuine correlation function K 2 (r). Here we have to take into account the fluctuation correction due to finiteness of the random chain. At L > R s the fluctuating contribution exceeds the correlation one.
The other important parameter of the random sequence is the memory length N . If the length N is less than R s , we have no difficulties to calculate the entropy of finite sequence, which can be considered as quasi-stationary. This case is illustrated in Fig. 3. If the memory length exceeds the stationarity length R s N , we have to take into account the fluctuation correction to the entropy. In Fig. 4 the plot of the differential entropy versus the length of words is shown as an illustration of importance of this correction. Both numerical and analytical results are presented for the same power-law correlation function as in Figs. 1 and 3. Comparing sums of squared correlation function K(r) = 0.01/r 1.1 with contribution (26), proportional to log 2 [M/(M − L], we find that they are equal at R s ≈ 10 4 . A graphical confirmation of this result is shown in the inset of Fig. 4. We can conclude that the dashed lines better approximate theoretical solid curves than dotted lines (till L ≈ 10 4 ). The nonmonotone decrease of h(L) is due to the fluctuation of random quantity, the entropy of the finite sequence.

VI. APPLICATION TO WRITTEN TEXTS
A theory of additive Markov chains with long-range memory was used for a description of correlation properties of literary texts [9]. The coarse-grained naturally written texts were shown to be strongly correlated sequences that possess anti-persistent properties at small distances (in the region L ≤ 300 of grammatical rules action). At long distances (in the region L ≥ 300 of semantic rules action) they manifest weak persistent power-law correlations. It is clear that our model of the additive Markov chain can only claim to describe the weak powerlaw part of entropy, proportional to L −γ .
Ebeling and Nicolis [12] and Schürmann and Grassberger [13] suggested the empirical form of entropy for written texts There emerges a natural question about the origin of this dependence. The partial answer to the question is as follows. The entropy of the Markov chain with step-wise memory function (10) in the limit of strong correlations, N ln N (1 − 2µ) ≪ 4µ, was obtained in Ref. [14] After comparing the results of Eqs. (21) and (30) with that of Eq. (29), it becomes clear that the term log 2 L describes strong short-range correlations and the power-law term L −γ is responsible for weak long-range correlations. So, we need a combined model that could unify two approaches of the additive Markov chain exposed above and the Markov chain with a step-wise memory function.
The answer to the question of which part of the correlation or memory function is responsible for the decimation invariance is still unsolvable.

VII. CONCLUSION AND PERSPECTIVES
(i) The main result of the paper, the differential entropy of the stationary ergodic binary weakly correlated random sequence A is given by Eq. (22). The other important point of the work is the calculation of the fluctuation contribution to the entropy due to finiteness of random chains, the last term in Eq. (28).
(ii) In order to obtain Eq. (22) we used an assumption that the random sequence of symbols is the Markov chain. Nevertheless, the final result contains only the correlation function, does not contain the conditional probability function of the Markov chain. This allows us to suppose that result (22) and the region of its applicability is wider than the assumptions under which it is obtained [16].
(iii) To obtain Eq. (22) we have supposed that correlations in the random chain are weak. This is not a very severe restriction. Many examples of such systems, described by means of the pair correlator are given in Ref. [4]. The randomly chosen example of DNA sequences supports this conclusion. The strongly correlated systems, which are opposed to weakly correlated chains, are nearly deterministic. For their description we need completely different approach. Their study is beyond the scope of this paper.
(iv) The developed theory opens a way for constructing a more consistent and sophisticated approach describing the systems with long-range correlations. Namely, Eq. (22) can be considered as expansion of the entropy in series with respect to the small parameter δ, where the entropy h 0 of the non-correlated sequence is the zero approximation. Alternatively, for the zero approximation we can use the exactly solvable model of the N -step Markov chain with the conditional probability function of words occurring taken in the form of the step-wise function, Eq. (10). Another way to choose the zero approximation can be based on CPF obtained from probability of the bloc occurring Eq. (15).
(v) In this paper we have considered the random sequences with the binary space of states, but almost all results can be generalized to non-binary sequences and can be applied for describing natural written and DNA texts.
(vi) Our consideration can be generalized to the Markov chain with the infinite memory length N . In this case we have to impose a condition on the decreasing rate of the correlation function and the conditional probability function at N → ∞.
Here we prove Eq. it follows that its solution is given by