Next Article in Journal
Lane-Based Vehicle Counting System for Complex Traffic Scenes
Previous Article in Journal
A Lightweight and Efficient Deep Learning Model Based on Improved YOLOv12 for Fall Detection in College Sport Activities
Previous Article in Special Issue
Mapping Research Trends with the CoLiRa Framework: A Computational Review of Semantic Enrichment of Tabular Data
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance †

Department of Information Engineering, University of Padova, 35131 Padova, Italy
*
Author to whom correspondence should be addressed.
This paper is an extended version of our paper published in String Processing and Information Retrieval, SPIRE 2019, Segovia, Spain, 7–9 October 2019.
Information 2026, 17(7), 685; https://doi.org/10.3390/info17070685
Submission received: 30 May 2026 / Revised: 9 July 2026 / Accepted: 11 July 2026 / Published: 14 July 2026
(This article belongs to the Special Issue Advances in Information Studies)

Abstract

The edit distance is a metric of dissimilarity between strings, widely applied in computational biology, speech recognition, and machine learning. Let e k ( n ) denote the average edit distance between random, independent strings of n characters from an alphabet of size k. This paper is concerned with the efficient computation of α k ( n ) = e k ( n ) / n as well as of α k = lim n α k ( n ) . It is shown that α k ( n ) Θ ( log n / n ) α k α k ( n ) and that α k is computable. An algorithm for the exact computation of α k ( n ) is presented with running time T = O ( n 2 k min ( 3 n , k n ) ) thus, of limited practical use. An analysis of Monte Carlo estimates, based on McDiarmid’s inequality, shows how α k ( n ) can be evaluated with good accuracy and high confidence level, for rather large values of n. In particular, 99.9% confidence intervals of width approximately 10 2 are obtained for α k . An efficiently computable lower bound β k * to α k is derived, with lim k β k * = 1 . For k greater than a few dozens, significant bounds on α k can be obtained faster via β k * than by statistical methods. The above techniques yield improvements on most previous numerical estimates as well as results for alphabet sizes and string lengths not reported before.

1. Introduction

Measuring dissimilarity between strings is a fundamental problem in computer science, with applications in computational biology, speech recognition, machine learning, and other fields. One commonly used metric is the edit distance(or Levenshtein distance), defined as the minimum number of substitutions, deletions, and insertions necessary to transform one string into the other.
It is natural to ask what is the expected distance between two randomly generated strings, as the string size grows; knowledge of the asymptotic behavior has proved useful in computational biology [1] and in nearest neighbor search [2], to mention a few examples.
In computational biology, the question often arises whether two strings (e.g., two DNA reads) are noisy copies of the same source or of non-overlapping sources. In several cases of interest, the source is modeled as a sequence of independent and identically distributed symbols (see, e.g., [1,3], with reference to DNA) and the noise is modeled with substitutions, insertions, and deletions (a good approximation for technologies like PacBio and MinION [4]). Then, the statistical inference may be based on a comparison of the distance between the observed strings with either the expected distance between a string and a noisy copy of itself, or the expected distance between two random strings.
Even for uniform and independent strings, the study of the expected edit distance appears to be challenging and little work has been reported on the problem. In contrast, the closely related problem of computing the expected length of the longest common subsequence has been extensively studied, since the seminal work by Chvátal and Sankoff [5].
Using Fekete’s lemma, it can be shown that both metrics tend to grow linearly with the string size n [6]. Specifically, let e k ( n ) denote the expected edit distance between two random, independent strings of length n on a k-ary alphabet; then α k ( n ) = e k ( n ) / n approaches (from above) a limit α k [ 0 , 1 ] . Similarly, let l k ( n ) denote the expected length of the longest common subsequence; then γ k ( n ) = l k ( n ) / n approaches (from below) a limit γ k [ 0 , 1 ] . The  γ k ’s are known as the Chvátal-Sankoff constants. The efficient computation of the exact values of α k and γ k is an open problem. This paper establishes the computability of α k , for any k, and proposes methods for estimating and bounding α k , also reporting numerical results for various alphabet sizes k.
From the perspective of computational complexity, we remark that, for the problem of computing α k ( n ) , given input n (for a fixed k), only algorithms that run in doubly exponential time and use exponential space are currently known, including those presented in this paper. Observe that the input size is log 2 n , the number of bits needed to specify the problem input n. Similar statements hold for the computation of γ k ( n ) . Therefore, at the state of the art, we can place these problems in the complexity class EXPSPACE ⊆ 2-EXPTIME, but not in EXPTIME and, a fortiori, not in PSPACE ⊆ EXPTIME. Technically, these are traditionally defined as classes of decision problems, hence our statements strictly apply to suitable decision versions of computing the constants of interest. Specifically, the decision version of computing α k could take as inputs a (positive) integer n and an integer r such that 0 r k log 2 n + log 2 n and output the r-th digit of A k ( n ) = k n n α k ( n ) . (Observe that 0 A k ( n ) k n n , whence A k ( n ) can be expresses with n log 2 k + log 2 n bits.) Analogous considerations can be made for the problem of computing the ν most significant bits of α k (or γ k ). Here, the input size is log 2 ν and the time becomes triple exponential in the input size. Whether these problems inherently exhibit high complexity or they can be solved efficiently by exploiting a not yet uncovered deeper structure remains to be seen.

1.1. Related Work

The guaranteed, deterministic bounds presented in this paper were first published in [7]. A preliminary version of this article was published in [8] and cited in the subsequent work by Rosenfeld [9] discussed below. Details on additions and improvements of this article with respect to the conference version [7] are given in Section 1.3.
There is limited literature directly pursuing bounds and estimates for α k . It is also interesting to review results on γ k : on the one hand, bounds to γ k give bounds to α k ; on the other hand, techniques for analyzing γ k can be adapted for analyzing α k .
The only published estimates of α k can be found in [1] which gives α 4 0.518 for the quaternary alphabet and α 2 0.29 for the binary alphabet. Estimates of γ k are given by Bundschuh [10], in particular γ 2 0.8126 and γ 4 0.6544 . A similar value is reported in [11], which gives γ 2 0.8124 . Estimates of γ k by sampling are given by  [12]; their conjecture that γ 2 > 0.82 appears to be at odds with the estimate in [10]. In [13], the conjecture γ 2 0.8122 is proposed. They also derive a closed form for the limit constant when only one string is random and the other is a periodic string containing all symbols of  k .
The best published analytical lower bounds to α k are α 4 0.3383 for a quaternary alphabet and α 2 0.1578 for a binary alphabet [1]. Recently, Rosenfeld [9] published the first systematic study of upper bounds to α k . Using an adaptation of the technique developed by Lueker for γ k [14], they established α 2 0.315514 and α 4 0.56578 (as well as bounds for different values of k). The best known analytical lower and upper bounds to γ 2 are given by [14] and improved by [15], who obtained 0.792665 γ 2 0.82628 . For larger alphabets, the best lower bounds are given by  [15] and the best upper bounds are given by [11], including 0.6143 γ 4 0.7082 . From known relations between the edit distance and the length of the longest common subsequence, it follows that 1 γ k α k 2 ( 1 γ k ) . Thus, upper and lower bounds to α k can be respectively obtained from lower and upper bounds to γ k . From  γ 2 0.8263 of [14], we obtain α 2 0.1737 , which is tighter than the bound given in [1]. Instead γ 4 0.7082 of [11] yields α 4 0.2918 , which is weaker than the bound α 4 0.3383 [1]. From the weaker relation ( 1 γ 2 ) / 2 α 2 , ref. [2] obtained the looser bound α 2 0.0869 . In this paper, we derive improved bounds, for both α 2 and α 4 , as well as bounds on α k , for values of k not fully addressed by earlier literature. Some of our techniques resemble those used in [16] for estimating γ k . Table 1 shows lower bounds to α k for various values of k based on this work and on that of previous authors. Lower bounds from [11,14] are obtained from upper bounds to γ k , which we have translated into α k 1 γ k . Dančík reported values of the bound only for k 15 . Lueker reported only the numerical upper bound to γ 2 ; his computational approach is interesting and sophisticated, but its time and space are exponential with k. Experimenting with (a minor adaptation of) the software provided by the author, we have not been able to compute γ 3 within reasonable time. We have obtained the values reported in the Ganguly et al. column by numerically solving their equations (in [1], only the values for k = 2 and k = 4 were reported). The equations underlying the results in the rightmost column of Table 1 are developed in Section 6, together with a rigorous analysis of their numerical solution.
To assess the tightness of bounds to γ k , several authors have investigated the rate of convergence of γ k ( n ) to γ k . The bound 0 γ k γ k ( n ) O ( log n / n ) has been obtained by [17] and, with a smaller constant, by [18]. Lueker [14] introduced a sequence of upper bounds γ k h converging to γ k and satisfying 0 γ k h γ k O ( ( log h / h ) 1 / 3 ) , where the time complexity and the space complexity of computing γ k h increase exponentially with h. Observing that h is in turn exponential in the number ν of desired bits for γ k and that ν is exponential in the input size log 2 ν , we see that computation time is a triple exponential. No study of the rate of convergence of α k ( n ) to α k has been published. In this paper, we show that 0 α k ( n ) α k O ( log n / n ) , exploiting a framework developed in [18].
Recently, Tiskin [19] has established that γ 2 is an algebraic number, introducing novel ideas, which may open new perspectives on the analysis of γ k and α k , for any k.

1.2. Paper Contributions and Organization

The notation and definitions used throughout this paper are given in Section 2. In Section 3, an upper bound α k ( n ) α k Q ( n ) is derived, for each k 2 , where Q ( n ) = Θ ( log n / n ) is a precisely specified function (independent of k). This implies α k [ α k ( n ) Q ( n ) , α k ( n ) ] , where the interval can be made arbitrarily small by choosing a suitably large n. One corollary is the computability of the real number α k , for each k 2 . Unfortunately, the algorithm underlying the computability proof is of little practical use, since the only known method to exactly compute α k ( n ) is by direct application of its definition, resulting in O ( n 2 k 2 n ) time. Even after some improvement presented in Section 5, the upper bound α k α k ( n ) is practically computable only for small values of k and n. Moreover, for the feasible values of n, Q ( n ) is too large for the lower bound α k α k ( n ) Q ( n ) to be useful. These considerations motivate the exploration of alternate approaches.
In Section 4, an analysis, based on McDiarmid’s inequality, is developed for Monte Carlo estimates of α k ( n ) obtained from the edit distance of a sample of N pairs of strings. The analysis yields the radius Δ of confidence intervals for α k ( n ) , in terms of n, N, and the desired confidence level λ . The (sequential) time to obtain an estimate can be approximated as T τ e d n Δ 2 ln 2 1 1 λ , where τ e d is of the order of 5 ns, on a typical state of the art processor core. Rather large values of n can then be dealt with. As an indication, a  λ = 0.999 confidence interval of radius Δ = 0.67 × 10 3 is obtained for α k ( 2 15 ) in about 43 min. The corresponding confidence interval for α k has radius Δ + Q ( 2 15 ) 2 = 0.00068 + 0.01320 = 0.01388 .
In Section 5, upper bounds to α k by exact computation of α k ( n ) for small values of n are obtained, by introducing an O ( n 2 ( 3 k ) n ) time algorithm that, while still exponential in n, is (asymptotically and practically) faster than the straightforward, O ( n 2 ( k 2 ) n ) time, algorithm. When k is of the order of a few dozens, only very small values of n are feasible and α k ( n ) does not differ appreciably from the quantity 1 1 k , which satisfies α k ( n ) 1 1 k , as it can be easily shown by allowing only substitutions (cf. Hamming distance).
In Section 6, a lower bound α k β k * is established, for each k 2 . A counting argument provides a lower bound to the number of string pairs with distance at least β n ; an asymptotic analysis provides conditions on β under which the contribution to α k ( n ) of the remaining string pairs vanishes with n. A careful study leads to a numerical algorithm to compute β k * , the supremum of the β ’s satisfying such conditions, with any desired accuracy, ϵ . Since, as shown in Section 6, lim k β k * = 1 , the interval [ β k * , 1 1 k ] , which contains α k , has size vanishing with increasing k. For k large enough, it becomes a subset of a confidence interval obtained with comparable computational effort. As an example, β 2 40 * 0.999984 α 2 40 1 2 40 0.999999 , placing α 2 40 in an interval of size smaller than 0.16 × 10 4 . To achieve Q ( n ) 0.16 × 10 4 requires n 10 11 . On a single core, computing the edit distance for just one pair of strings of length n = 10 11 would take time T 5 × 10 9 10 22 s 1.6 × 10 6  years, whereas computing β 2 40 * took just 14 milliseconds, using a straightforward, non-optimized implementation.
By applying the above methodologies, we numerically derive guaranteed as well as statistical estimates for specific α k ’s and α k ( n ) ’s. In particular, Table 2 summarizes our numerical results for various alphabet sizes. For each k, the table reports an interval that provably contains α k and a (narrower) interval that contains α k with confidence 0.999 . For the confidence interval, more details are provided in Section 4, while for the guaranteed bounds, details are given in Section 5 and Section 6.
In Section 7, we wonder about the asymptotic behavior of α k , with respect to k. We propose and motivate the conjecture that lim k ( 1 α k ) k = c α for some constant c α 1 . Numerical evidence indicates that perhaps 3 c α 4 .
Finally, Section 8 presents conclusions and further directions of investigation.

1.3. Summary of Contributions

We now schematically summarize the key contributions of this paper. Those marked by a “*” represent novelties with respect to an earlier, conference version [7] of this work.
  • (*) An analysis of the rate of convergence of α k ( n ) to α k .
  • (*) A proof that α k is a computable real number.
  • The coalesced dynamic programming algorithm, which can be exploited to obtain the exact value of α k ( n ) , unfortunately practical only for small values of n.
  • (*) An analysis of the statistical estimates for α k , achieving largely improved confidence intervals (over analogous results in [7]), with a different approach based on McDiarmid’s inequality.
  • A combinatorially derived lower bound on α k .
  • (*) An extensive proof of correctness of the algorithm proposed to compute the lower bound on α k , with any desired precision.
  • (*) A conjecture on the behavior of α k for large k.

2. Preliminaries

In this section, we introduce the notation adopted throughout the paper and present some preliminary definitions and results used in various parts of the work.

2.1. Notation and Definitions

Let k be a finite alphabet of size k 2 and let n 1 be an integer; a stringx is a sequence of symbols x [ 1 ] x [ 2 ] x [ n ] where x [ i ] k ; n is called the length (or size) of x, also denoted by | x | . k n is the set of all strings of length n.

2.1.1. Edit Distance

We consider the following edit operations on a string x: the match of x [ i ] , the substitution of x [ i ] with a different symbol b k { x [ i ] } , the deletion of x [ i ] , and the insertion of b k in position j = 0 , , n (insertion in j means b goes after x [ j ] or at the beginning if j = 0 ); an edit script is a sequence of edit operations. With each type of edit operation is associated a cost; throughout this paper, matches have cost 0 and other operations have cost 1. The cost of a script is the sum of the costs of its operations. The edit distance between x and y, d E ( x , y ) , is the minimum cost of any script transforming x into y. It is easy to see that | | x | | y | | d E ( x , y ) max ( | x | , | y | ) .

2.1.2. Simple Scripts

We can view a string as a sequence of cells, each containing a symbol from k , and consider edit operations as acting on such cells: a deletion destroys a cell, a substitution changes the content of a cell, and an insertion creates a new cell with some content in it (matches leave cells untouched). We will say that a script is simple if it performs at most one edit operation on each cell. It is easy to see that, if a script transforming x into y is not simple, then there is a script with fewer operations which achieves the same transformation. In fact, if a cell is eventually deleted, any operation performed on it prior to its deletion can be safely removed from the script; if a cell is inserted, any subsequent substitution can be removed, appropriately selecting the content of the initial insertion; and multiple substitutions on a cell that is retained can be either replaced by just one appropriate substitution or removed altogether. Thus, a script of minimum cost is necessarily simple, so that, to determine d E ( x , y ) , we can restrict our attention to simple scripts.

2.1.3. Scripts and Alignments

Given an edit script transforming x into y, consider those cells of x that are retained in y, possibly with a different content. Since the relative order of two such cells is the same in x and in y, the positions occupied by such cells in x and y form an alignment, in the sense defined next.
An alignment  ( I , J ) between x and y is a pair of increasing integer sequences of the same length s
I = ( i 1 , , i s ) 1 i 1 < i 2 < < i s | x | , J = ( j 1 , , j s ) 1 j 1 < j 2 < < j s | y | .
The positions i l in x and j l in y are said to be to be aligned in ( I , J ) . To each script S , there corresponds a unique alignment a ( S ) = ( I , J ) , where s equals the number of cells of x that are retained in y and, for every l = 1 , 2 , , s , the cell in position i l of x has moved to position j l of y. If  S is simple, then: (i) for aligned positions i l and j l , y [ j l ] is substituted with or matched to x [ i l ] depending on whether y [ j l ] x [ i l ] or not; (ii) for positions i I , x [ i ] is deleted, and (iii) for positions j J , y [ j ] is inserted.
Next, we prove a simple lemma, which will be useful both in Section 3, to cast edit distance within the framework of [18], and in Section 6, to develop a counting argument leading to a lower bound on α k .
Lemma 1. 
With the preceding notation, if  S is a simple script to transform x into y, with | x | = | y | = n , and  ( I , J ) = a ( S ) is the corresponding alignment, its cost is
c o s t ( x , y , S ) = 2 ( n s ) + l = 1 s ( x [ i l ] y [ j l ] ) .
Proof. 
The script performs ( n s ) deletions, ( n s ) insertions, and  l = 1 s ( x [ i l ] y [ j l ] ) substitutions. □
We may observe that (for given x and y) simple scripts corresponding to the same alignment differ only with respect to the order in which the edit operations are applied. Such an order does not affect the final result, since in a simple script different operations act on different cells. Thus, the number of distinct simple scripts with the same alignment is the factorial of their cost (i.e., of the number of edit operations), given by Equation (1).

2.1.4. Random Strings and the Limit Constant

A random string of length n, X = X [ 1 ] X [ 2 ] X [ n ] , is a sequence of random symbols X [ i ] generated according to some distribution over k . We will assume that the X [ i ] ’s are uniformly and independently sampled from k or, equivalently, that Pr [ X = x ] = k n for every x k n . We define the eccentricity ecc ( x ) of a string x as its expected distance from a random string Y k n :
ecc ( x ) = k n y k n d E ( x , y ) .
The expected edit distance between two random, independent strings of k n is:
e k ( n ) = k 2 n x k n y k n d E ( x , y ) = k n x k n ecc ( x ) .
Let α k ( n ) = e k ( n ) / n ; it can be shown (Fekete’s lemma from ergodic theory; see, e.g., Lemma 1.2.1 in [6]) that there exists a real number α k [ 0 , 1 ] , such that
lim n α k ( n ) = α k .
The main objective of this paper is to derive estimates and bounds to α k .

2.1.5. Rate of Convergence to the Limit Constant

In the outlined context, it is of interest to develop upper bounds, as  functions of n, to the quantity
q k ( n ) = α k ( n ) α k ,
which we will refer to as the rate of convergence, following a terminology widely used for analogous quantities in the context of the longest common subsequence (e.g., [17,18]).

2.2. Computing the Edit Distance

The edit distance and the length of the longest common subsequence (LCS) can be computed by a dynamic programming algorithm. Given two strings, x of length n and y of length m, their edit distance d E ( x , y ) is obtained as the entry M n , m of an ( n + 1 ) × ( m + 1 ) matrix M , computed according to the following recurrence:
M i , 0 = i for i = 0 , , n M 0 , j = j for j = 0 , , m M i , j = min ( M i 1 , j 1 + ξ i , j , M i 1 , j + 1 , M i , j 1 + 1 ) for i > 0 and j > 0
where ξ i , j = 0 if x [ i ] = y [ j ] and ξ i , j = 1 otherwise. (A similar algorithm computes the length of the LCS. Recurrence (5) becomes M i , 0 = 0 , M 0 , j = 0 , and M i , j = max ( M i 1 , j 1 + ( 1 ξ i , j ) , M i 1 , j , M i , j 1 ) . ) This algorithm takes O ( n m ) time and space. An edit script transforming x into y can be obtained backtracking on M , along a path from cell ( n , m ) to cell ( 0 , 0 ) . For both edit distance and LCS, the approach by [20], exploiting the method of the Four Russians, reduces the time to O ( n 2 log n ) , assuming n m . Although asymptotically faster, the algorithm in [20] is seldomly used. Other approaches are usually preferred, such as the one proposed by [21], which reduces the n 2 bound by a factor proportional to the machine word size, implementing Recurrence (5) via bit-wise operations.
The space complexity of the basic dynamic programming algorithm can be reduced to O ( min ( n , m ) ) . Assuming, w.l.o.g., that n m , simply proceed row-wise storing only the last complete row. While this approach is not directly amenable to constructing scripts by backtracking, a more sophisticated divide and conquer version due to Hirschberg [22] yields the edit distance and an edit script in quadratic time and linear space. In [23], authors applied the Four Russians method to Hirschberg’s algorithm, improving its running time by a logarithmic factor.
It is known that both the edit distance and the length of the LCS cannot be computed in time O ( n 2 ϵ ) , unless the Strong Exponential Time Hypothesis (SETH) is false ([24,25]).
Approximate computation of the edit distance has been extensively studied. Ukkonen [26] presents a banded algorithm that computes an approximation within a factor O ( n 1 ϵ ) in time O ( n 1 + ϵ ) . Interestingly, this algorithm computes the exact distance whenever such distance is O ( n ϵ ) (although, it may output the exact distance also for higher values). In [27] authors give an algorithm that computes the exact distance in time O ( n + d 2 ) , where d is the distance itself. Thus, sub-quadratic time can be achieved when the distance is sub-linear. More recently, an  ( log n ) O ( 1 / ϵ ) approximation, computable in time O ( n 1 + ϵ ) , was proposed by  [28], and a constant approximation algorithm with running time O ( n 1 + 5 / 7 ) was proposed by  [29,30]. The work by [31] gives a reduction from approximate length of the longest common subsequence to approximate edit distance, proving that the algorithm in [29] can also be used to approximate the length of the LCS.
In order to compute upper bounds to α k , we propose an algorithm related to the approaches developed by [14,32]. In these works, portions of the dynamic programming matrix are associated to the states of a finite state machine. Our algorithm conceptually simulates all possible executions of a machine similar to the one defined in [32].

3. Rate of Convergence and Computability of α k

For each n, α k ( n ) is a rational number, which can be computed, according to Equation (3), by exhaustively enumerating all pairs ( x , y ) of strings in k n and accumulating the corresponding values d E ( x , y ) , which can be obtained with any algorithm for the exact edit distance. On the other hand, the limit constant α k is known to exist as a real number, whose rationality remains an open problem. In this section, we show that, for every k, this number is computable, according to the following (standard) definition.
Definition 1  (Computability of a real number). 
A real number ζ is computable if there exists an algorithm that, given as input a rational number ϵ > 0 , outputs a rational number ζ ϵ , such that | ζ ζ ϵ | < ϵ .
As shown in [33], the subadditivity of a sequence of rational numbers, while sufficient to guarantee the existence of a limit (Fekete’s Lemma, [34]), is not sufficient to guarantee its computability which, if present, requires an additional argument. For  α k , such an argument can be provided along the following steps:
  • Prove that, for some computable function b k ( n ) , we have
    α k ( n ) α k b k ( n ) n 1 .
  • Show that there is an algorithm which, given a rational number ϵ > 0 , computes an integer n ϵ 1 such that
    b k ( n ) < ϵ n n ϵ .
  • Let α k , ϵ = α k ( n ϵ ) and observe that
    0 < α k , ϵ α k < b k ( n ϵ ) < ϵ ,
    thus complying with Definition 1 (with ζ = α k and ζ ϵ = α k , ϵ ), since n ϵ is computable from ϵ and α k , ϵ = α k ( n ϵ ) is computable from n ϵ .
To obtain a bound b k ( n ) such that Equation (6) is satisfied, we show how the edit distance problem can be cast within a framework developed in [18], to analyze the limit average behavior of certain functions of random string pairs on a finite alphabet . These functions are formally defined next.
Definition 2. 
Let S : × R 0 + be a symmetric ( S ( b , a ) = S ( a , b ) ), non-negative, real function and let δ be a real number. The score of a pair of strings x , y n , with respect to a given alignment ( I , J ) , is defined as
S ( x , y ; I , J ) = l = 1 s S ( x [ i l ] , y [ j l ] ) + δ ( n s ) .
The score of the string pair is the maximum score over all possible alignments:
S ( x , y ) = max ( I , J ) S ( x , y ; I , J ) .
Next, we express the edit distance in terms of a suitable score.
Proposition 1.
For a , b k let
S ( a , b ) = 0 i f a b 1 otherwise
and let δ = 1 . Then, for  x , y k n ,
d E ( x , y ) = n S ( x , y ) .
Proof. 
Considering a given alignment ( I , J ) , we can write
n S ( x , y ; I , J ) = n l = 1 s S ( x [ i l ] , y [ j l ] ) ( 1 ) ( n s ) = 2 ( n s ) + s l = 1 s S ( x [ i l ] , y [ j l ] ) = 2 ( n s ) + l = 1 s ( x [ i l ] y [ j l ] ) .
Recalling Lemma 1, the quantity in the last row can be recognized as the cost of the simple scripts S transforming x into y, with alignment a ( S ) = ( I , J ) . Further recalling that optimal scripts are simple, we conclude that maximizing the score with respect to the alignment minimizes the cost of the edit script, whence the claimed Equality (9). □
The preceding proposition enables the application of the following far reaching result to the analysis of the average edit distance.
Theorem 1
([18]). Let X and Y be random strings in n , whose symbols are all mutually independent and equally distributed. Let l ( n ) = 1 n E X , Y S ( X , Y ) , where E denotes the expectation operator, and let l = lim n l ( n ) . Then
l l ( n ) A 2 n 1 n + 1 n 1 + ln ( n 1 ) + F n 1 : = Q A , F ( n ) .
where A = max a , b S ( a , b ) and F = max a , b , c | S ( a , b ) S ( a , c ) | .
The preceding theorem makes no assumption on the probability distribution of the symbols. Moreover, Q A , F ( n ) is independent of such distribution, although the quantities l ( n ) and l are not. Here, we assume the uniform distribution, upon which we have based the definition of α k ( n ) . As a corollary of Theorem 1 and Proposition 1, we obtain the computability of α k .
Theorem 2.
For any integer k > 0 , the limit constant α k defined in Equation (4) satisfies the bound
α k ( n ) α k 2 n 1 n + 1 n 1 + ln ( n 1 ) + 1 n 1 : = Q ( n ) ,
for n 2 . Therefore, α k is a computable real number.
Proof. 
It is an exercise to see that, for the score function S ( a , b ) of Proposition 1, A = F = 1 , for any k. Correspondingly, we have Q ( n ) = Q 1 , 1 ( n ) . We also observe that, with  = k , using Equation (9), we have
α k ( n ) = 1 n E X , Y d E ( X , Y ) = 1 1 n E X , Y S ( X , Y ) = 1 l k ( n ) α k = 1 l k .
Thus, Equation (11) follows from Equation (10), with  Q ( n ) = Q 1 , 1 ( n ) , considering that α k ( n ) α k = ( 1 l k ( n ) ) ( 1 l k ) = l k l k ( n ) . Finally, it is straightforward to prove that there is an integer n ¯ such that Q ( n ) is strictly decreasing for n n ¯ and that n ϵ = min { n n ¯ : Q ( n ) < ϵ } is a computable function of the rational number ϵ . □
Interestingly, Q ( n ) , hence n ϵ , is independent both of the alphabet size, k, and of the probabilities of symbols in the alphabet . However, computing α k ( n ϵ ) , to obtain a deterministically guaranteed ϵ -approximation of α k , will require work increasing with k, at least with the currently known approaches that are sensitive to the number k n of strings of length n, as we will see in the coming sections. Moreover, n ϵ increases more than quadratically with 1 / ϵ (see Equation (11)), making the approach completely impractical. More specifically, to obtain ν bits of α k we need ϵ = 2 ν , so that n ϵ 1 / ϵ 2 = 4 ν and k n ϵ k 4 ν , which is a triple exponential in the problem size log 2 ν .
Remark 1.
Although, both for simplicity and for homogeneity with other sections, we have stated Theorem 2 for the case of uniform distribution on the alphabet symbols, the arguments that have been developed are easily adapted to establish the computability for the analog of α k , under any distribution. In fact, as already observed, Q A , F ( n ) is independent of the distribution and the quantities analog to the l ( n ) ’s are trivially (although inefficiently) computable by summing the distances d E ( x , y ) over all pairs x , y k n , duly weighted by their probabilities.
We point out that, in the same spirit of this section, the computability of γ k can be derived from any of the rate-of-convergence bounds given by [14,17,18].

4. Monte Carlo Estimates of α k

In this section, motivated by the difficulty of the exact computation, we develop an analysis of Monte Carlo estimates of α k ( n ) , by sampling, and translate them into estimates of α k , using Theorem 2. We will see how α k ( n ) can be estimated with high confidence and good accuracy for values of n up to a quarter million, with less than one core-hour of computation. For  α k , we achieve an error of the order of 10 2 .
Intuitively, for fixed k and n, we expect the estimate error to be proportional to 1 / N , where N is the number of samples (string pairs), and to the standard deviation S k ( n ) / n of the single sample d E ( x , y ) / n . Experimentally, this standard deviation appears to decrease a bit faster than 1 / n , (We do not report here on this experimental observation systematically; however, estimates of S 4 ( n ) for some values of n can be found in Table 3) with the implication that, to obtain the same error on α k ( n ) , fewer samples suffice for larger n. However, the behavior of the standard deviation does not appear easy to establish analytically. Fortunately, the edit distance function has the property that, if only one position is modified in just one of the input strings, the (absolute value of the) variation of the distance is at most 1. This property enables the use of McDiarmid’s inequality to bound from above the probability that d E ( x , y ) / n deviates from the mean by more than a certain amount, by a negative exponential in the square of that amount. This paves the way to the desired analysis. In fact, McDiarmid’s inequality can be applied directly to the average over N samples, dealing in a uniform way with the “averaging” effect within a single pair of strings and across multiple pairs.
  • Preview of results
To help navigate this section, we preview its results, with a preliminary interpretation.
In Section 4.1, we present Monte Carlo estimates of α k ( n ) for which we develop confidence intervals based on McDiarmid’s inequality. The results for the quaternary alphabet (column α ˜ 4 ( n , N ) of Table 3) show that these values converge from above to α k . We observe that the differences α ˜ 4 ( n , N ) α ˜ 4 ( 2 n , N ) decrease with n, suggesting that the estimates become more precise as n increases, even if the confidence intervals become wider, due to the smaller sample size N, manageable within a given computational budget. The dependence of α k ( n ) upon k is investigated Table 4. Here, all confidence intervals have the same width, since the same values of n and N are used for different k’s.
In Section 4.2, we derive estimates of α k (the limit of α k ( n ) ) and corresponding confidence intervals. These estimates for k = 4 (column α ^ k ( n , N ) in Table 5) are obtained as the center point of a confidence interval depending on both statistical interval and the bound Q ( n ) on α k ( n ) α k . Interestingly, the width of such interval is largely due to Q ( n ) . Furthermore, the bound appears to be loose, since the values α ^ k ( n , N ) converge to α k from below, whereas the α ˜ k ( n , N ) converge from above. Table 6 presents estimates of α k for various k, along with confidence intervals (all of equal width, as the same n and N have been fixed for all k’s). The comparison between statistical estimates of α k ( n ) and confidence intervals for α k is also visually illustrated in Figure 1.

4.1. α k ( n )

Given N random and independent pairs of strings ( X 1 , Y 1 ) , , ( X N , Y N ) from k n , we consider the random variable
α ˜ k ( n , N ) = 1 n e ˜ k ( n , N ) = 1 n N i = 1 N d E ( X i , Y i ) .
Clearly, E [ α ˜ k ( n , N ) ] = α k ( n ) . To assess the quality of α ˜ k ( n , N ) as an estimate for α k ( n ) , we resort to McDiarmid’s inequality, briefly reviewed next.
Proposition 2
([35]). Let Z = ( Z 1 , , Z 2 m ) be a vector of 2 m independent random variables. Let f ( Z ) be a real function and let B > 0 be a real constant such that, if  Z and Z differ in at most one component, then | f ( Z ) f ( Z ) | B . Then, for every Δ 0 ,
Pr [ | f ( Z ) E [ f ( Z ) ] | > Δ ] exp Δ 2 m B 2 .
In the present context, based on the previous proposition, we can formulate confidence intervals for α k ( n ) , as follows.
Proposition 3 (Confidence intervals for α k ( n ) ).
For any Δ 0 , the (random) interval [ α ˜ k ( n , N ) Δ , α ˜ k ( n , N ) + Δ ] is a confidence interval for the parameter α k ( n ) , with confidence level 1 2 exp ( N n Δ 2 ) , that is:
Pr [ α ˜ k ( n , N ) Δ α k ( n ) α ˜ k ( n , N ) + Δ ] 1 2 exp N n Δ 2 .
Proof. 
We apply Proposition 2 to the function f given by the rightmost term in Equation (12), with  Z being the concatenation the 2 N strings x i ’s and y i ’s, each comprising n variables (over k ), so that m = N n . We can set B = 1 N n , since changing one string position changes the sum of the N edit distances by at most 1, and the quantity 1 / ( N n ) times the sum by at most 1 / ( N n ) . Therefore, considering that m B 2 = ( N n ) ( 1 / ( N n ) 2 ) = 1 / ( N n ) , we can write:
Pr [ α ˜ k ( n , N ) α k ( n ) > Δ ] exp N n Δ 2 .
Symmetrically, it can be shown that
Pr [ α ˜ k ( n , N ) α k ( n ) < Δ ] exp N n Δ 2 .
Combining Inequalities (15) and (16), after simple algebra, yields Inequality (14). □
Remark 2.
Propositions 2 and 3 only require that the symbols of the random strings are statistically independent, not necessarily with the same distribution. The numerical results reported next refer to the special case where all symbols are uniformly distributed, which underlies the definition of α k ( n ) and e k ( n ) . However, the approach could be straightforwardly applied to other, possibly position-dependent, distributions. Interestingly, for given n and N, the width of the confidence interval, for a given confidence level (e.g.,  Δ 99.9 % ( n , N ) in Table 3), is independent of the distribution.
  • Numerical Results
Table 3 reports estimates based on Monte Carlo estimates, within the framework of Proposition 3. The alphabet size is k = 4 , a case of special interest in DNA analysis (e.g., [1,36]). For the string length n, the values considered are the powers of two from 2 8 = 256 to 2 18 = 262,144. For each n, the number of samples N has been chosen as N = 2 39 / n 2 . This choice (roughly) equalizes the amount of (sequential) computation time devoted to each n, when the edit distance for a sample pair is computed by a quadratic algorithm, say, in time T e d ( n ) = τ e d n 2 , for some constant τ e d , making the overall time for N samples T ( n , N ) = τ e d N n 2 . In our experiments, this becomes T ( n , 2 39 / n 2 ) = τ e d 2 39 2560 s ≈ 43 min, where we measured τ e d 1.25 × 2 28  s ≈ 4.66 ns, on a state-of-the-art processor core. From Inequality (14), straightforward manipulations show that, if the target is a confidence level λ , then the radius Δ of the confidence interval becomes:
Δ λ ( n , N ) = 1 N n ln 2 1 λ .
Choosing λ = 0.999 and recalling that, in our experiments, we have set N = 2 39 / n 2 , the above formula becomes
Δ 99.9 % ( n , 2 39 / n 2 ) = 2 39 n ln 2000 = 2 20 3.90 n .
Thus, for  n = 2 8 , we have Δ 99.9 % = 0.59 × 10 4 . For  n = 2 18 , we have Δ 99.9 % = 0.19 × 10 2 . The values of Δ 99.9 % have been used, together with the experimental values of α ˜ 4 ( n , N ) , to obtain the confidence intervals reported in the last column of Table 3, as [ α ˜ 4 ( n , N ) Δ 99.9 % ( n , N ) , α ˜ 4 ( n , N ) + Δ 99.9 % ( n , N ) ] .
Table 4 reports estimates of α k ( n ) for various alphabet sizes k. The confidence intervals shown in the last column of the table are based on the confidence level λ = 0.999 . The estimates are obtained from numerical experiments involving N = 2 9 random pairs of strings of length n = 2 15 . Since the radius of the confidence interval only depends on λ , n, and N (but not k), the same value Δ 99.9 % ( 2 15 , 2 9 ) 0.67 × 10 3 applies to all k’s. Notice that the standard deviation S ˜ k ( n , N ) tends to decrease with k; this makes intuitive sense since, for fixed n, as k increases, the probability that every symbol that appears in one string is distinct from every symbol that appears in the other string approaches 1, so that almost all pairs of strings have distance n, hence the variance is negligible.

4.2. α k

The following proposition provides confidence intervals for α k , when the quantity α ˜ k ( n , N ) Q ( n ) / 2 is used as an estimator, where Q ( n ) bounds the rate of convergence, according to Equation (11).
Proposition 4 (Confidence intervals for α k ).
For any Δ 0 , the (random) interval centered at α ˜ k ( n , N ) Q ( n ) / 2 and of radius Δ + Q ( n ) / 2 , i.e.,
I k ( n , N , Δ ) = [ ( α ˜ k ( n , N ) Q ( n ) / 2 ) ( Δ + Q ( n ) / 2 ) , ( α ˜ k ( n , N ) Q ( n ) / 2 ) + ( Δ + Q ( n ) / 2 ) ]
is a confidence interval for α k , with confidence level 1 2 exp ( N n Δ 2 ) , i.e.,
Pr [ α k I k ( n , N , Δ ) ] 1 2 exp N n Δ 2 .
Proof. 
By Theorem 2 and the fact that α k < α k ( n ) , we have that α k ( n ) Q ( n ) α k α k ( n ) . By Inequality (14), this implies
Pr [ α ˜ k ( n , N ) Q ( n ) Δ α k α ˜ k ( n , N ) + Δ ] 1 2 exp N n Δ 2 .
To arrive at Inequality (19), it remains to observe that the interval within the probability is just a rewriting of I k ( n , N , Δ ) . □
From Proposition 4, straightforward manipulations show that, if the target confidence level is λ , then the radius R λ ( n , N ) of the confidence interval becomes:
R λ ( n , N ) = Q ( n ) 2 + 1 N n ln 2 1 λ .
The first term arises because α k ( n ) is a (deterministically bounded) approximation to α k and the second term because α ˜ k ( n , N ) is a (statistically bounded) approximation to α k ( n ) . To get a sense of the relative weight of the two terms contributing to the radius, we observe that, from Equation (11), we can approximate the first term as Q ( n ) 2 ln n 2 n . Therefore, even using just one sample pair ( N = 1 ), this term dominates the second one as soon as n > 2 1 λ 2 . For  λ = 0.999 , we get n > 4 × 10 6 .
Remark 3.
It is interesting to observe that the size 2 R λ ( n , N ) of the confidence interval is independent of the alphabet size k. The same applies to the computational work, T ( n , N ) = τ e d N n 2 + l . o . t . , to obtain the statistical estimate of α k ( n ) with a given confidence.
Our estimate of α k is the center of the interval I k ( n , N , Δ ) as defined in Proposition 4
α ^ k ( n , N , Δ ) = α ˜ k ( n , N ) Q ( n ) / 2 .
Table 5 reports these estimates for k = 4 , based on the values α ˜ 4 ( n , N ) reported in Table 3 and on Proposition 4 for confidence level λ = 0.999 .
Table 6 reports estimates of α k , for various values of k, all based on numerical experiments with N = 2 9 samples of string pairs of size n = 2 15 . The corresponding confidence interval I k ( n , N , Δ ) is obtained at confidence level λ = 0.999 . All intervals have radius R 0.999 ( 2 15 , 2 9 ) 1.4 × 10 2 .

5. Upper Bounds for α k

In this section, we present methods to derive upper bounds to α k based on the exact computation of α k ( n ) = e k ( n ) / n for some n, and on the relation α k α k ( n ) , valid for all n 1 . The computation of e k ( n ) can be reduced to that of the eccentricity, as in Equation (3) repeated here for convenience:
e k ( n ) = k n x k n ecc ( x ) .
If ecc ( x ) is computed according to Equation (2) and the distance d E ( x , y ) is computed by the O ( n 2 ) -time dynamic programming algorithm for each of the k n strings y k n , then the overall computation time is O ( n 2 k n ) for ecc ( x ) and O ( n 2 k 2 n ) for e k ( n ) , since the eccentricity of each of the k n strings x k n is needed in Equation (22). Below, we propose a more efficient algorithm to speed up the computation of ecc ( x ) and, in turn, that of e k ( n ) , achieving time O ( n 2 min ( k , 3 ) n k n ) = O ( n 2 3 n k n ) . We also show how to exploit some symmetries of ecc ( x ) in order to limit the computation of the eccentricity needed to obtain e k ( n ) to a suitable subset of k n .

5.1. The Coalesced Dynamic Programming Algorithm for Eccentricity

Let M ( x , y ) be the matrix produced by the dynamic programming algorithm (reviewed in Section 2.2) to compute d E ( x , y ) , with  x , y k n . We develop a strategy to coalesce the computations of M ( x , y ) for different y k n , while keeping x fixed. To this end, we choose to generate the entries of M ( x , y ) , according to Equation (5), in column-major order. Clearly, column j is fully determined by x and by the prefix of y of length j. Define now the column multiset C j containing column j (i.e., the last one) of M ( x , y [ 1 ] y [ j ] ) for each string y [ 1 ] y [ j ] k j . The multiset C j is a function of (just) x, although, for simplicity, the dependence upon x is not reflected in our notation. Clearly, each column in C j 1 generates k columns in C j , one for each symbol of k ; therefore the cardinality of C j is | C j | = k j . However, several columns may be equal to each other, so that the number of distinct such columns can be much smaller. In fact, we will show that this number is upper bounded by 3 n , which is smaller than k j for j > log 2 3 log 2 k n . This circumstance can be exploited to save both space and computation, by representing C j as a set of records each containing a distinct column and its multiplicity. Intuitively, we are coalescing the computation of the dynamic programming matrices corresponding to different strings, when such matrices happen to have the same j-th column.
The Coalesced Dynamic Programming (CDP) algorithm described next (referring also to the line numbers of Algorithm 1), constructs the sequence of multisets C 0 , C 1 , , C n . A column multiset C will be represented as a set of pairs ( c , μ ( c ) ) , one for each distinct member c , with  μ ( c ) being the multiplicity of c in C . The eccentricity of x is obtained (lines 13-17) as the weighted average of the n-th elements of all columns in C n :
ecc ( x ) = k n c C n μ ( c ) c [ n ] .
As can be seen from Equation (5), multiset C 0 contains the column ( 0 , 1 , , n ) , with multiplicity 1 (line 3). For  j = 1 , , n , C j is obtained by scanning all c C j 1 (line 6) and all b k (line 7), and by
  • computing the j-th column c resulting from Equation (5) when the ( j 1 ) -st column is c and ξ i , j = 0 if x [ i ] = b or else ξ i , j = 1 (call to NextColumn( x , c , j , b ), line 8);
  • inserting μ ( c ) copies of c in C j , by either creating a new pair ( c , μ ( c ) ) when c is not present in the multiset or by incrementing its multiplicity by μ ( c ) otherwise (call to Insert( C j , ( c , μ ( c ) ) ), line 9).
The correctness of the CDP algorithm is pretty straightforward to establish. A few observations are however necessary in order to describe and analyze a data structure that can efficiently implement, in our specific context, multisets with the insertion operation. The key property is that, for  j = 0 , 1 , n , the column of M ( x , y ) with index j satisfies the conditions (a) M 0 , j = j and (b) ( M i , j M i 1 , j ) { 1 , 0 , 1 } , for  i = 1 , , n . Using this property, the set of distinct columns that belong to the multiset C j can be represented as a ternary tree where each arc has a label from the set { 1 , 0 , 1 } and a column ( M 0 , j , M 1 , j , , M n , j ) is mapped to a leaf v such that the n arcs in the path from the root to v have labels ( M 1 , j M 0 , j ) , , ( M n , j M n 1 , j ) . Each leaf stores the multiplicity of the corresponding column. The size of the tree for C j is O ( min ( 3 n , k j ) ) , since there are at most 3 n columns satisfying the constraints and k j k-ary strings that contribute (not necessarily distinct) columns. Hence, the body of the loop, whose iteration range is defined in lines 4, 6, and 7, is executed n k O ( min ( 3 n , k j ) ) times. Considering that one call to NextColumn() as well as one call to Insert() can be easily performed in O ( n ) time, we can summarize the previous discussion as follows, where we also consider that, at any given time, the algorithm only needs to store two consecutive column multisets.
Algorithm 1 Coalesced dynamic programming algorithm to compute ecc ( x )
  1:
procedure Eccentricity(x)
  2:
     n | x |
  3:
     C 0 { ( ( 0 , 1 , , n ) , 1 ) }
  4:
    for  j 1  to n do
  5:
         C j
  6:
        for ( c , μ ( c ) ) C j 1  do
  7:
           for  b k  do
  8:
                c NextColumn( x , c , j , b )
  9:
               Insert( C j , ( c , μ ( c ) ) )
10:
           end for
11:
        end for
12:
    end for
13:
     e 0
14:
    for  c C n  do
15:
         e e + μ ( c ) c [ n ]
16:
    end for
17:
    return  e / k n
18:
end procedure
Proposition 5.
The CDP algorithm computes the eccentricity ecc ( x ) of a string x of length n over a k-ary alphabet in time T = O ( n 2 k min ( 3 n , k n ) ) and space S = O ( min ( 3 n , k n ) ) . Correspondingly, the expected distance e k ( n ) can be computed in time T = O ( n 2 k n + 1 min ( 3 n , k n ) ) and space S = O ( min ( 3 n , k n ) ) .
Remark 4.
The CDP algorithm can be easily generalized to handle the case where ecc ( x ) is defined with respect to a random string y whose symbols are independently, but not necessarily uniformly, distributed. Moreover, the distribution does not need to be stationary. In other words, the probability of the string y [ 1 ] y [ n ] has the form j = 1 n p j ( y [ j ] ) . Essentially, rather than maintaining the multiplicity of each column μ ( c ) , we maintain its probability π ( c ) . The rules to obtain C j from C j 1 are straightforward. The eccentricity is obtained as c C n π ( c ) c [ n ] . This generalized version of the CDP algorithm naturally enables the computation of the expected edit distance between two random strings x and y whose symbols are all mutually independent. The computational bounds remain those stated in Proposition 5.

5.2. Exploiting Symmetries of ecc ( x ) in the Computation of e k ( n )

The edit distance enjoys some useful symmetries, which can be easily derived from the definition. One is that, if we let x R = x [ n ] x [ 1 ] denote the reverse of the string x = x [ 1 ] x [ n ] , then d E ( x , y ) = d E ( x R , y R ) . Another one is that if π : k k is a permutation of the alphabet symbols and π ( x ) denotes the string π ( x [ 1 ] ) π ( x [ n ] ) , then d E ( x , y ) = d E ( π ( x ) , π ( y ) ) . The following is a simple, but useful corollary of these properties.
Proposition 6.
For any x k n , we have ecc ( x R ) = ecc ( x ) . Furthermore, for any permutation π of k , we have ecc ( π ( x ) ) = ecc ( x ) .
It is useful to define the equivalence class of x as the set of strings that have the same eccentricity as x, due to Proposition 6, and denote by ν ( x ) the cardinality of such set. If R k , n k n contains exactly one (representative) member for each equivalence class, then Equation (22) can be rewritten as
e k ( n ) = k n x R k , n ν ( x ) ecc ( x ) .
Computing e k ( n ) according to Equation (24) enables one to reduce the number of strings for which the eccentricity has to be computed (via the CDP algorithm) by a factor slightly smaller than ( 2 k ! ) , with a practically appreciable reduction in computation time.
The strategy outlined in this section has been implemented in C++ and run on a 32 core IBM Power7 server. For several alphabet sizes k, we have considered values of n up to a maximum value n k u b , under the constraint that the running time would not exceed one week. The resulting values e k ( n k u b ) are presented in Table 7. For the quaternary alphabet, we obtain α 4 0.6318 , which is rather loose because based on a small string length, namely n 4 u b = 15 . The limitation on the string length is obviously due to the high complexity of the algorithm. In contrast, the statistical estimate presented in Section 4 is based on much longer strings and represents a more accurate approximation of α 4 , although the estimate comes with a confidence interval, rather than with a deterministic guarantee.
We mention that the CDP algorithm could perhaps be improved, by a constant factor related to the machine word-size, with the bit-vector approach presented in [21], or by a factor logarithmic with n, with the Four Russians method in [20]. Considering the exponential nature of the CDP algorithm, however, these approaches are unlikely to yield substantial improvements of the deterministic upper bound and we have not pursued them.

6. Lower Bounds for α k

In this section, we establish a lower bound β k * to α k , for each k 2 . We first characterize β k * analytically, as the supremum of a suitably defined set of real numbers, and then provide an efficient algorithm to compute β k * , within any desired approximation. We focus on the expression of e k ( n ) in terms of eccentricities, given in the second line of Equation (3). We derive lower bounds to ecc ( x ) by ignoring the contribution of the strings inside the ball of radius r centered at x and by setting to r + 1 the contribution of the string outside the same ball. The objective is to determine the largest value r k * ( n ) of r for which (it can be shown that) the ball of radius r contains a fraction of k n that vanishes with n; then r k * ( n ) / n will converge to a lower bound to α k . Below, we formalize this idea and show that we can choose r k * ( n ) = β k n for suitable values of β k independent of n; this establishes that α k β k * , where β k * is the supremum of such values. It is shown that lim k β k * = 1 and β k * α k 1 1 k , whence, for k large enough, β k * provides an increasingly accurate estimate of α k . Thus, we turn our attention to translating the analytical characterization of β k * into an efficient numerical algorithm for its computation, a translation which is not completely straightforward. Finally, we present the numerical values of our lower bound for a sample of alphabet sizes.

6.1. Lower Bounds to ecc ( x ) from Upper Bounds to Ball Size

In this subsection, we derive lower bounds to ecc ( x ) based on upper bounds to the size of the ball of radius r centered at x. Such bounds hold for every string x, but depend only upon the length n of x. They will be used to compute lower bounds to α k .
Definition 3.
For a string x k n , the ball of radius r centered at x is defined as the set of strings having edit distance at most r from x:
B k , r ( x ) = { y k n : d E ( x , y ) r } .
Similarly, the shell of radius r centered at x is defined as the set of strings having edit distance exactly r from x:
S k , r ( x ) = { y k n : d E ( x , y ) = r } .
The next lemma shows how an upper bound to the ball size can provide a lower bound to the eccentricity, thus motivating the derivation of such an upper bound.
Lemma 2.
Let u k , r ( x ) | B k , r ( x ) | ; then for every r * = 0 , 1 , , n :
ecc ( x ) r * 1 k n u k , r * ( x ) .
Proof. 
By partitioning k n into shells centered at x, we can rewrite (2) as
ecc ( x ) = k n r = 0 r * r | S k , r ( x ) | + k n r = r * + 1 n r | S k , r ( x ) | k n ( r * + 1 ) r = r * + 1 n | S k , r ( x ) | = k n ( r * + 1 ) | B k , n ( x ) | | B k , r * ( x ) | > r * 1 k n | B k , r * ( x ) | r * 1 k n u k , r * ( x ) ,
where, in the last two steps, the relationships | B k , n ( x ) | = k n and | B k , r * ( x ) | u k , r * ( x ) have been utilized. □
The bound u k , r * ( x ) we derive below depends only upon the length n of x so that it can be written as u k , r * ( n ) , with a harmless overloading of notation. Then, simple manipulations of Equation (3) show that
α k ( n ) = e k ( n ) n r * n 1 k n u k , r * ( n ) ;
α k = lim n α k ( n ) lim n r * n 1 k n u k , r * ( n ) .
We will show that, for suitable values of β k , letting r * = β k n , the quantity k n u k , β k n ( n ) converges to 0 whence, by Equation (27), α k β k .

6.2. Upper Bounds on Ball Size

To apply Lemma 2, we need an upper bound to | B k , r ( x ) | . The next proposition develops such an upper bound by (i) showing that every string y B k , r ( x ) can be obtained from x by applying a script of certain type with cost r or r 1 and (ii) counting such scripts. In general, the upper bound will not be tight, because the count may include multiple scripts that produce y from x.
Proposition 7.
For any x k n and for any r = 1 , , n
| B k , r ( x ) | ( k 1 ) r d = 0 r / 2 n d 2 n d + 1 r 2 d k ( k 1 ) 2 d .
Proof. 
We call canonical simple script (CSS) a simple script (see Section 2.1) where all deletions precede all substitutions, the latter precede all insertions and, within each type of operation, cells are processed from left to right. For any script transforming x into y, there is a CSS of non greater cost which achieves the same transformation. Therefore, if d E ( x , y ) = r , then there is a CSS of cost r which, applied to x, produces y. Each CSS of cost r { 0 , 1 , , n } can be constructed by a sequence of choices, as specified below (shown within square brackets is the number of possible choices):
  • d { 0 , 1 , , r / 2 }
  • d positions to delete from x [ n d ]
  • ( r 2 d ) of the remaining ( n d ) positions to be substituted [ n d r 2 d ]
  • d positions to insert in y [ n d ]
  • the symbols in the substitutions [ ( k 1 ) r 2 d ]
  • the symbols in the insertions [ k d ]
Straightforwardly, the number of CSSs of cost r is
s k , r = d = 0 r / 2 n d 2 n d r 2 d ( k 1 ) r 2 d k d .
Next, we prove that any y B k , r ( x ) can be obtained from x via a simple script of cost r 1 or r. Let r = d E ( x , y ) r . When r = r , an optimal script of cost r is also a simple script of the same cost. Hence, the canonical version of such optimal script can be used to obtain y from x. The same reasoning applies to the case r = r 1 . Finally, for r < r 1 , consider an optimal CCS of cost r that transforms x into y. By augmenting this script with ( r r ) / 2 pairs of deletions and insertions, each pair acting on a matched position, we obtain a simple script of cost r, if r r is even, or of cost r 1 if r r is odd. The prescribed augmentation is always possible since the number of matches is at least n r r r ( r r ) / 2 .
The thesis is then established by the following chain of inequalities:
| B k , r ( x ) | s k , r + s k , r 1 d = 0 r / 2 n d 2 n d r 2 d ( k 1 ) r 2 d k d + d = 0 ( r 1 ) / 2 n d 2 n d r 1 2 d ( k 1 ) r 1 2 d k d d = 0 r / 2 n d 2 n d r 2 d ( k 1 ) r 2 d k d + d = 0 r / 2 n d 2 n d r 1 2 d ( k 1 ) r 2 d k d = d = 0 r / 2 n d 2 n d + 1 r 2 d ( k 1 ) r 2 d k d ,
where we have made use of the identity
n d r 2 d + n d r 1 2 d = n d + 1 r 2 d .

6.3. Asymptotic Behavior of Ball Size and Bounds for α k

The next results show that the right hand side of Inequality (28), divided by k n , is bounded by a sum of exponential functions whose exponents all vanish with n, when the ball radius is set to β k n , with β k satisfying certain conditions (depending upon k). Intuitively, this means that, except for a vanishing fraction, all strings in k n lie outside of the ball B k , β k n ( x ) whence, by Equation (27), α k β k .
Definition 4.
Let H ( x ) , with 0 x 1 , denote the binary entropy function
H ( x ) = x log 2 x ( 1 x ) log 2 ( 1 x ) ,
and let H ( x ) = d H d x = log 2 1 x x and H ( x ) = d 2 H d 2 x = log 2 e x ( 1 x ) denote its first and second derivatives.
Definition 5.
For β [ 0 , 1 ] and δ [ 0 , β / 2 ] , we define the function
g k ( β , δ ) = ( β 2 δ ) log 2 ( k 1 ) ( 1 δ ) log 2 k + 2 H ( δ ) + ( 1 δ ) H β 2 δ 1 δ .
Lemma 3.
Let u k , r ( n ) be given by the right hand side of (28) and g k ( β , δ ) be given by (30). For every β [ 0 , 1 ] ,
k n u k , β n ( n ) ( n + 1 ) d = 0 β n / 2 2 n g k β , d n .
Proof. 
Using the relation
n d + 1 r 2 d = n d + 1 n r + d + 1 n d r 2 d ( n + 1 ) n d r 2 d ,
the bound n k 2 n H ( k / n ) (see, e.g., Equation (5.31) in [34]), and defining β = r / n , we get
k n u k , r ( n ) k n ( k 1 ) r d = 0 r / 2 n d 2 n d + 1 r 2 d k ( k 1 ) 2 d ( n + 1 ) d = 0 r / 2 2 2 n H d n + ( n d ) H r 2 d n d + ( r 2 d ) log 2 ( k 1 ) + ( d n ) log 2 k = ( n + 1 ) d = 0 β n / 2 2 n g k β , d n .
Theorem 3.
For integer k 2 and real β [ 0 , 1 ] , define the real function
G k ( β ) = max 0 δ β / 2 g k ( β , δ )
and the set of real numbers
A k = { β [ 0 , 1 ] : G k ( β ) < 0 } .
Then,
α k β k * : = sup A k .
Proof. 
First, we observe that the definition of G k ( β ) is well posed; in fact, for any fixed β [ 0 , 1 ] , the function g k ( β , δ ) is bounded and continuous with respect to δ , hence it attains a maximum value in the compact set 0 δ β / 2 (by Weierstrass Theorem).
Second, we observe that A k is not empty, since G k ( 0 ) < 0 . In fact, when β = 0 , the condition δ [ 0 , β / 2 ] is satisfied only by δ = 0 , and g k ( 0 , 0 ) = log 2 k < 0 , for any k 2 . Finally, since A k [ 0 , 1 ] , then sup A k 1 .
For β A k , letting f ( n ) = ( n + 1 ) β n 2 + 1 , we see from Lemma 3 that
k n u k , β n ( n ) ( n + 1 ) d = 0 β n / 2 2 n g k β , d n f ( n ) 2 n G k ( β ) ,
where we have used the relation g k β , d n G k ( β ) . The latter follows from the definition of G k ( β ) and the fact that, in each of the β n 2 + 1 terms of the summation, 0 d n β / 2 . Taking now the limit in (27) with r * = β n yields:
α k lim n β 1 f ( n ) 2 n G k ( β ) = β ,
as f ( n ) = O ( n 2 ) and 2 n G k ( β ) is a negative exponential. In conclusion, since α k is no smaller than any member of A k , it is also no smaller than β k * = sup A k . □
As a first application of Theorem 3, we obtain an analytical lower bound to each α k . This bound is generally not the best that can be obtained numerically from the theorem, but does provide some insight. In particular, it shows that, as k grows, both β k * and α k approach 1.
Proposition 8.
Let the constant M be defined as
M = max 0 β 1 0 δ β / 2 2 H ( δ ) + ( 1 δ ) H β 2 δ 1 δ 2.52
Then, for any k 3 , we have
α k β ^ k = 1 M log 2 ( k 1 ) .
Two obvious corollaries are that lim k β k * = 1 and lim k α k = 1 .
Proof. 
For k < 7 , β ^ k < 0 , thus, α k β ^ k is trivially satisfied (recall that α k 0 ). Hence, we assume, for the remainder of the proof, k 7 so that β ^ k 0 , leading to a well posed definition of M, since it involves a maximum of a bounded, continuous function over a compact domain. We need to show that g k ( β ^ k , δ ) < 0 for any δ [ 0 , β ^ k / 2 ] . By plugging the definition of β ^ k in (30), after simple manipulations, we obtain
g k ( β ^ k , δ ) = log 2 k log 2 ( k 1 ) δ ( 2 log 2 ( k 1 ) log 2 k ) M 2 H ( δ ) + ( 1 δ ) H β ^ k 2 δ 1 δ < 0 .
It is straightforward to check that the terms within each of the first two pairs of square brackets are positive for every k 3 , while the expression within the third pair of square brackets is non-negative (by the definition of M). Finally, we clearly have β ^ k β k * α k < 1 , hence the stated limits are implied by the fact that lim k β ^ k = 1 . □
The corollary lim k α k = 1 also follows from the result lim k γ k = 0 (Theorem 1 in [5]), together with the relationship 1 γ k α k , already mentioned in the introduction.

6.4. Numerical Computation of the Lower Bound

In this subsection, we develop numerical procedures, both to decide whether a specific (rational) number β qualifies as a lower bound to α k , according to Theorem 3 (i.e., whether g k ( β , δ ) < 0 for every δ [ 0 , β / 2 ] or, equivalently, G k ( β ) < 0 ) and to obtain the lower bound that subsumes all the β ’s (that is, β k * = sup A k ). The procedures presented below are based on some properties of the functions g k ( β , δ ) and G k ( β ) , which will be established, along the following lines.
  • We show analytically that g k ( β , δ ) , when viewed as a function of δ , for some fixed value of β , achieves its maximum at a unique point in its domain. By a bisection-like procedure, driven by the sign of the derivative g k δ , lower and upper bounds to such maximum, G k ( β ) , can be computed with any desired accuracy.
  • We then develop a partial procedure that returns sign ( G k ( β ) ) , when G k ( β ) 0 , and does not halt otherwise.
  • Finally, we show, analytically, that G k ( β ) is an increasing function taking both negative and positive values, so that the point β k * = sup A k is the only root of the equation G k ( β ) = 0 and can be (arbitrarily) approximated by a bisection-like procedure, driven by the sign of G k ( β ) .

6.4.1. Computing G k ( β )

For simplicity, in this subsection, we adopt an idealized infinite precision model, where we assume that (i) the (real) numbers arising throughout the computation are represented with infinite precision and (ii) the results of the four basic arithmetic operations, of comparisons, and of logarithms are computed exactly. We will discuss how to deal with the somewhat subtle issues of finite precision in the next subsection.
We begin by identifying an interval that contains G k ( β ) and then show how this interval can be made arbitrarily small.
Proposition 9.
Let 0 β 1 and let 0 < δ l < δ r < β / 2 be such that 0 < g k δ ( β , δ l ) < and < g k δ ( β , δ r ) < 0 . Let
y ( δ l , δ r ) = g k δ ( β , δ l ) g k δ ( β , δ r ) ( δ l δ r ) + g k δ ( β , δ l ) g k ( β , δ r ) g k δ ( β , δ r ) g k ( β , δ l ) g k δ ( β , δ l ) g k δ ( β , δ r )
be the ordinate of the intersection of the two straight lines tangent to the curve g k ( β , δ ) (for fixed β) at ( δ l , g k ( β , δ l ) ) and ( δ r , g k ( β , δ r ) ) , respectively. Then
G k ( β ) [ max g k ( β , δ l ) , g k ( β , δ r ) , y ( δ l , δ r ) ] .
To prove the above proposition, we will need the following lemma, which highlights some useful properties of g k δ .
Lemma 4.
Let 0 β 1 . Then, as δ increases from 0 to β / 2 , the derivative g k δ decreases from + to and vanishes at a unique point, ζ k ( β ) , where g k ( β , ζ k ( β ) ) = G k ( β ) .
Proof. 
From Equation (30), basic calculus operations yield
g k δ = log 2 k ( k 1 ) 2 + 2 H ( δ ) H β 2 δ 1 δ 2 β 1 δ H β 2 δ 1 δ .
Considering that lim x 0 + H ( x ) = + (see Definition 4), we have that lim δ 0 + g k δ = + (due to the second term), while lim δ β / 2 g k δ = (due to the fourth term). Taking one more derivative, after some cancellation of terms and simple rearrangements, we have
2 g k 2 δ = 2 H ( δ ) + ( 2 β ) 2 ( 1 δ ) 3 H β 2 δ 1 δ < 0 ,
where the last inequality follows from the fact that H ( x ) < 0 , for any 0 x 1 (see Definition 4). From 2 g k 2 δ < 0 , we have that g k δ is strictly decreasing and, considering that g k δ ( β , 0 + ) = + and g k δ ( β , β / 2 ) = , we conclude that g k δ takes each real value exactly once. Let then ζ k ( β ) be the (unique) point where g k δ ( β , ζ k ( β ) ) = 0 . It is straightforward to argue that this is the unique point of maximum of g k ( β , δ ) (with respect to δ , for fixed β ). Then, according to the definition of G k (see Theorem 3), G k ( β ) = g k ( β , ζ k ( β ) ) . □
Proof of Proposition 9. 
To better follow this proof, the reader may refer to the graphical illustration provided in Figure 2. The lower bound to G k ( β ) , in Equation (34), trivially follows from the fact that G k ( β ) is the maximum value of g k ( β , δ ) , for 0 δ β / 2 . To establish the upper bound, let x ( δ l , δ r ) be the abscissa of the intersection of the tangents (gray lines in Figure 2) considered in the statement (these tangents do intersect, since they have different slopes). Due to the downward convexity ( 2 g k 2 δ < 0 ) of g k ( β , δ ) , for any δ [ δ l , x ( δ l , δ r ) ] , the graph of g k ( β , δ ) lies below the tangent at ( β , δ l ) . Symmetrically, for any δ [ x ( δ l , δ r ) , δ r ] , the graph of g k ( β , δ ) lies below the tangent at ( β , δ r ) . Hence, for any δ [ δ l , δ r ] , the graph of g k ( β , δ ) lies below the ordinate y ( δ l , δ r ) of the intersection of the two tangents. In particular, G k ( β ) = g k ( β , ζ k ( β ) ) y ( δ l , δ r ) , since ζ k ( β ) [ δ l , δ r ] . □
Proposition 10
(Computability of G k , in the infinite precision model). There is a procedure (described in the proof) which, given as inputs an integer k 2 and two real values β [ 0 , 1 ] and ϵ > 0 , outputs an interval [ G , G ] such that G k ( β ) [ G , G ] and G G < ϵ .
Proof. 
The proposed procedure distinguishes 2 cases.
Case 1: g k δ ( β , β / 4 ) = 0 . Here, β / 4 = arg max δ g k ( β , δ ) , whence G k ( β ) = g k ( β , β / 4 ) . The procedure outputs G = G = g k ( β , β / 4 ) , clearly satisfying the requirements in the statement.
Case 2: g k δ ( β , β / 4 ) 0 . Here the procedure includes two phases. In a first phase, a bisection process determines two points, δ 0 l and δ 0 r , which satisfy the assumptions of Proposition 9. (For simplicity, the dependence of δ 0 l and δ 0 r upon k and β is not made explicit in the notation.) In a second phase, the interval [ δ 0 l , δ 0 r ] is iteratively bisected, until the interval appearing in Equation (34) has size smaller than ϵ . In both phases, the bisection is driven by the sign of g k δ . The first phase includes two subcases:
Subcase 2a: g k δ ( β , β / 4 ) > 0 . We define the sequence μ j = ( 1 2 j ) ( β / 2 ) , for j 1 . Letting h = min { j 2 : g k δ ( β , μ j ) < 0 } , we set [ δ 0 l , δ 0 r ] = [ μ h 1 , μ h ] .
Subcase 2b: g k δ ( β , β / 4 ) < 0 . We define the sequence ν j = 2 j ( β / 2 ) , for j 1 . Letting h = min { j 2 : g k δ ( β , ν j ) > 0 } , we set [ δ 0 l , δ 0 r ] = [ ν h , ν h 1 ] .
Since lim j μ j = β / 2 and lim j ν j = 0 , the interval [ δ 0 l , δ 0 r ] is well defined, in either subcase. Its endpoints can be computed by iteratively testing the condition on the derivative for j = 1 , 2 , , till it is satisfied.
In both subcases, ζ k ( β ) [ δ 0 l , δ 0 r ] . We can then construct a sequence of intervals, each half the size of the preceding one and containing ζ k ( β ) , as follows.
For i = 1 , 2 , do:
  • c i = ( δ i 1 l + δ i 1 r ) / 2 .
  • If g k δ ( β , c i ) = 0 , then set G = G = g k ( β , c i ) and exit.
  • If g k δ ( β , c i ) > 0 , then let [ δ i l , δ i r ] = [ c i , δ i 1 r ] .
  • If g k δ ( β , c i ) < 0 , then let [ δ i l , δ i r ] = [ δ i 1 l , c i ] .
  • Set G = max ( g k ( β , δ i l ) , g k ( β , δ i r ) ) and G = y ( δ i l , δ i r ) , as defined in Proposition 9. If G G < ϵ , then exit.
It is straightforward to show that, for any η > 0 , log 2 ( 1 / η ) bisection iterations (counting those of both phases) are sufficient to guarantee δ r δ l η , hence to determine ζ k ( β ) with accuracy η > 0 .
It remains to show that the above for loop is eventually exited. If the loop is exited at step 2, then we are are done. Otherwise, as we will argue, G G vanishes with δ r δ l so that, for some i, G G < ϵ , hence the loop is eventually exited, at step 5. Toward this conclusion, we can observe that
y ( δ l , δ r ) g k ( β , δ l ) g k δ ( β , δ l ) ( x ( δ l , δ r ) δ l ) , y ( δ l , δ r ) g k ( β , δ r ) g k δ ( β , δ r ) ( δ r x ( δ l , δ r ) ) ,
where x ( δ l , δ r ) is the abscissa of the intersection of the tangents. As δ r δ l approaches 0, we have that
lim δ l = lim δ r = lim x ( δ l , δ r ) = ζ k ( β ) , lim g k δ ( β , δ l ) = lim g k δ ( β , δ r ) = 0 , lim G G = lim y ( δ l , δ r ) max ( g k ( β , δ l ) , g k ( β , δ r ) ) = 0 .

6.4.2. Computing sign ( G k ( β ) )

We now consider the more realistic model where only rational numbers are represented, and only arithmetic operations and comparisons with rational inputs can be computed exactly. If f ( x ) is a real function of the real variable x, we will restrict our attention to rational inputs and be interested in computing arbitrary approximations of f ( x ) . More specifically, our target is an approximation algorithm  A f ( x , ϵ ) of the rational inputs x and ϵ > 0 , whose output f ˜ ( x , ϵ ) satisfies the relationship | f ˜ ( x , ϵ ) f ( x ) | < ϵ . Thus, f ( x ) is a computable real number, in the sense of Definition 1. These notions naturally extend to functions of several variables.
Approximation algorithms are well known for log 2 x , such as the iterative method of [37]. For evaluating a finite arithmetic expression, a tedious but straightforward analysis of error propagation will determine the required accuracy of each intermediate calculation capable of guaranteeing the desired accuracy for the target result. Therefore, approximation algorithms can be derived for g k ( β , δ ) and g k δ ( β , δ ) .
One issue we need to deal with is that an algorithm to compute f ( x ) with any desired accuracy does not automatically translate into an algorithm to systematically determine the sign (positive, negative, or zero), of f ( x ) , denoted sign ( f ( x ) ) . In fact, while f ˜ ( x , ϵ ) + ϵ implies f ( x ) > 0 and f ˜ ( x , ϵ ) ϵ implies f ( x ) < 0 , in the remaining case, | f ˜ ( x , ϵ ) | < ϵ , nothing can be inferred about sign ( f ( x ) ) . On the one hand, when f ( x ) = 0 , this “undeterminate” case is bound to occur, for any ϵ > 0 . On the other hand, when f ( x ) 0 , this case will not occur if ϵ | f ( x ) | / 2 , since | f ˜ ( x , ϵ ) f ( x ) | < ϵ | f ( x ) | / 2 implies | f ˜ ( x , ϵ ) | | f ( x ) | / 2 ϵ .
The preceding observations suggest the following procedure S ( A f , x ) which, building on an algorithm A f that computes an approximation f ˜ ( x , ϵ ) to f ( x ) , will halt and output sign ( f ( x ) ) { , + } , when f ( x ) 0 and will not halt when f ( x ) = 0 . Given a monotonically vanishing, computable sequence ϵ 1 , ϵ 2 , (e.g., ϵ i = 2 i ), for i = 1 , 2 , , the procedure S computes f ˜ i = f ˜ ( x , ϵ i ) by a call to A f ( x , ϵ i ) ; if f ˜ i ϵ i or f ˜ i ϵ i , then it returns sign ( f ˜ i ) and halts.
The bisection procedure has to be modified so that it will not get stuck in the attempt of evaluating the sign of a zero. Assuming that f has a unique zero in the interval [ a , b ] , say, with f ( a ) < 0 and f ( b ) > 0 , a point c where to split the interval can be found as follows. Let c = ( 2 a + b ) / 3 and c = ( a + 2 b ) / 3 the points that trisect the interval. Interleave the executions of the calls S ( A f , c ) and S ( A f , c ) until the termination of one of them, an event guaranteed to occur since at least one between f ( c ) and f ( c ) differs form zero. Let c be the argument for which the execution has terminated, whence sign ( f ( c ) ) has been determined. The refined interval is chosen to be [ a , c ] when f ( c ) > 0 and [ c , b ] when f ( c ) < 0 . In all cases, the interval size shrinks at least by 2 / 3 .
With the tools we have introduced, we can now tackle the finite-precision computation of sign ( G k ( β ) ) , a quantity that will play a key role in the computation of β k * discussed in the next subsection.
Proposition 11
(Partial computability of sign ( G k ( β ) ) , in the finite precision model). There is a procedure (described in the proof) which, given as inputs an integer k 2 and two rational values β [ 0 , 1 ] and ϵ > 0 , outputs sign ( G k ( β ) ) and halts, if G k ( β ) 0 , and does not halt, if G k ( β ) = 0 .
Proof. 
We obtain the procedure for sign ( G k ( β ) ) by adapting the procedure to approximate G k ( β ) presented in the proof of Proposition 10. To lighten the notation, throughout this proof, we let g ( δ ) = g k ( β , δ ) and g ( δ ) = g k δ ( β , δ ) .
Interleave the executions of the calls S ( A g , β / 4 ) and S ( A g , β / 8 ) until termination of one of them, an event guaranteed to occur since at least one between g ( β / 4 ) and g ( β / 8 ) differs form zero. Let δ 0 be the argument for which the execution has terminated. If g ( δ 0 ) > 0 , then search for a μ h such that g ( μ h ) < 0 and let [ δ 0 l , δ 0 r ] = [ δ 0 , μ h ] . Else g ( δ 0 ) < 0 , search for a ν h such that g ( ν h ) > 0 and let [ δ 0 l , δ 0 r ] = [ ν h , δ 0 ] . The search has to interleave the evaluation of two consecutive points in the sequence, to avoid the potential non termination of the execution, which can occur at most at one point.
The sequence [ δ i l , δ i r ] , for i = 1 , 2 , , of successive refinements of [ δ 0 l , δ 0 r ] is then constructed, choosing the splitting point c i by trisection. Let ϵ i be the error bound such that the call to A g ( c i , ϵ i ) has enabled the determination of the sign of g ( c i ) . Let also η i = min ( 2 i , ϵ i ) and compute η i -approximations g ˜ ( δ i l , η i ) , g ˜ ( δ i r , η i ) , and y ˜ ( δ i l , δ i r , η i ) . The conditions that enable determining sign ( G k ( β ) ) are as follows:
  • If g ˜ ( δ i l , η i ) η i or g ˜ ( δ i r , η i ) η i , then return sign ( G k ( β ) ) = + and halt.
  • If y ˜ ( δ i l , δ i r , η i ) η i , then return sign ( G k ( β ) ) = and halt.
Indeed, in the first case, the condition implies that g ( δ i l ) = g k ( β , δ i l ) > 0 or g ( δ i r ) = g k ( β , δ i r ) > 0 , which in turn implies G k ( β ) > 0 . Conversely, if G k ( β ) > 0 , for i large enough, both g ( δ i l ) and g k ( δ i r ) , which are monotonically non decreasing with i, become positive. Since η i vanishes with i, it will eventually become sufficiently small to satisfy the condition.
Symmetrically, in the second case, the condition implies that G k ( β ) < 0 . Conversely, if G k ( β ) < 0 , for i large enough, y ( δ i l , δ i r ) , which decreases with i, becomes negative. Again, η i will eventually become sufficiently small to satisfy the condition.
Finally, we observe that if G k ( β ) = 0 , then neither condition will ever hold and the procedure will not halt. □

6.4.3. Computing β k * = sup A k

In this subsection, we will see that the set A k is an interval, closed on the left and open on the right: specifically, A k = [ 0 , β k * ) . On the one hand, this property of A k is not surprising, since if β is a lower bound to α k and β < β , then β is a lower bound too. On the other hand, the property does require a proof, since membership in A k is a sufficient, but not necessary condition for β to be a lower bound, a scenario compatible with A k having “holes”, that is, with G k ( β ) taking both negative and positive values to the left of β k * . However, we will argue that A k has no such holes, since G k ( β ) has a unique zero in [ 0 , 1 ] which, by Equation (33), is our target, β k * = sup A k . We will show this zero to be computable.
Proposition 12.
For every k 2 , in the interval 0 β 1 , the function G k ( β ) is increasing and has a unique zero, which equals β k * = sup A k .
Proof. 
From Lemma 4, we have that G k ( β ) = g k ( β , ζ k ( β ) ) , where ζ k ( β ) is the unique solution of the equation (in δ ) g k δ ( β , δ ) = 0 , so that
g k δ ( β , ζ k ( β ) ) = 0 .
By the chain rule for the total derivative and the above relationship, we get
G k β = g k β ( β , ζ k ( β ) ) β β + g k δ ( β , ζ k ( β ) ) ζ k ( β ) β = g k β ( β , ζ k ( β ) ) = log 2 ( k 1 ) + H β 2 ζ k ( β ) 1 ζ k ( β ) ,
where the last step follows from Equation (30). After several but simple manipulations and letting ζ = ζ k ( β ) , the expression just derived together with Equations (37) and (35) yield the relationship
2 β 1 ζ G k β = log 2 k k 1 + 2 H ( ζ ) H β 2 ζ 1 ζ + 1 β 2 ζ 1 ζ log 2 ( k 1 ) .
We will argue that the right hand side is positive, for any β [ 0 , 1 ] and any ζ [ 0 , β / 2 ] . As easily seen, the only negative term in the right hand side of Equation (38) is H β 2 ζ 1 ζ 1 . A case analysis shows that this negative term is offset by one or more of the remaining terms, yielding a positive sum.
Case 1: ζ < 1 / ( 1 + 2 ) . Considering that H is monotonically decreasing (see Definition 4), we have
2 H ( ζ ) > 2 H 1 1 + 2 = 2 log 2 1 1 / ( 1 + 2 ) 1 / ( 1 + 2 ) = 2 log 2 2 = 1 .
Case 2: ζ 1 / ( 1 + 2 ) and k 4 . We observe that 1 β 2 ζ 1 ζ is decreasing with β and increasing with ζ , whereas log 2 ( k 1 ) is increasing with k, whence
1 β 2 ζ 1 ζ log 2 ( k 1 ) > 1 1 2 / ( 1 + 2 ) 1 1 / ( 1 + 2 ) log 2 ( 3 ) > 1 2 1.58 > 1.11
Case 3: ζ 1 / ( 1 + 2 ) and k = 2 . The right hand side of Equation (38) becomes
1 + 2 H ( ζ ) H β 2 ζ 1 ζ ,
which is always positive. In fact, if ζ < 1 / 2 , then 2 H ( ζ ) > 0 and 1 H β 2 ζ 1 ζ 0 . On the other hand, if ζ = 1 / 2 , then 2 H ( ζ ) = 0 ; furthermore, it must be β = 1 so that H β 2 ζ 1 ζ = H ( 0 ) = 0 .
Case 4: ζ 1 / ( 1 + 2 ) and k = 3 . Considering that (i) H ( ζ ) 0 (for 0 ζ 1 / 2 ) , (ii) H ( x ) 1 (for any 0 x 1 ), and (iii) 1 β 2 ζ 1 ζ > 1 2 (as seen in Case 2), Equation (38) implies
2 β 1 ζ G k β log 2 3 2 1 + 1 2 > 0.58 1 + 0.70 = 0.28 > 0 .
Having established that G k ( β ) has a positive derivative, hence it is increasing, in the interval [ 0 , 1 ] , we now argue the existence of a (unique) zero of G k ( β ) , by showing that G k ( 0 ) < 0 and G k ( 1 ) > 0 , for every k 2 .
At β = 0 , we simply observe that, by definition (i.e., Equation (32)), we have G k ( 0 ) = max 0 δ 0 g k ( 0 , δ ) = g k ( 0 , 0 ) = log 2 k < 0 , for every k 2 .
At β = 1 , we observe that G k ( 1 ) = max 0 δ 1 / 2 g k ( 1 , δ ) g k ( 1 , 1 / k ) and show that g k ( 1 , 1 / k ) > 0 , for every k 2 . We consider the following chain of relationships where, starting from Equation (30), (i) we have dropped the contribution ( 1 δ ) log 2 1 1 δ to H ( δ ) and the second entropy term, which are both non-negative; (ii) we have plugged β = 1 and δ = 1 k ; and (iii) we have performed simple algebraic manipulations, also making use of the inequality log 2 ( 1 + x ) ( log 2 e ) x :
g k ( 1 , 1 / k ) 1 2 1 k log 2 ( k 1 ) 1 1 k log 2 k + 2 1 k log 2 k = log 2 k 1 k + 2 k log 2 k k 1 + 1 k log 2 k ( log 2 e ) 1 2 k 1 k + 1 k log 2 k = 1 k log 2 k ( log 2 e ) 1 2 k .
For k = 2 , the expression within the square bracket evaluates to 1. For k 3 , it is easy to see that the square bracket is positive, as log 2 k ( log 2 e ) 1 2 k > log 2 3 log 2 e > 0 . In conclusion, for every k 2 , we have g k ( 1 , 1 k ) > 0 , as claimed.
Finally, given that G k ( β ) is increasing with β , its unique zero is the supremum β k * of A k (cf. Equation (33)). □
We can now present a simple numerical algorithm to approximate β k * , from below, with any desired accuracy.
Proposition 13.
(Computability of β k * , in the finite precision model). There is a procedure (outlined in the proof) which, on inputs k 2 and ϵ > 0 , outputs a number β ¯ k * [ β k * ϵ , β k * ] . Clearly, β ¯ k * α k .
Proof. 
In light of Proposition 12, it is straightforward to develop a trisection procedure that starts with the interval [ 0 , 1 ] , is driven by the sign of G k ( β ) computed according to Proposition 11, stops after log 3 / 2 1 ϵ iterations, and outputs the left endpoint of the current interval containing β k * , which has size smaller than ( 3 / 2 ) log 3 / 2 1 ϵ ϵ . □
Table 8 reports the lower bound β ¯ k * (approximating β k * from below), for a set of values of k. The program we have used is based on a direct implementation of the bisection version of the relevant procedures. For the level of accuracy of the reported results, the precision of standard floating point arithmetic turns out to be sufficient. The execution is rather fast: even the result for k = 2 40 took about 15 milliseconds of core-time to compute, even using a non-optimized, straightforward implementation of the bisection algorithm. As a term of comparison, the table also shows the value of the simple upper bound α k 1 1 k (from Hamming distance). Considering that, from Proposition 8, lim k ( α k β k ) = 0 , we see how, as k increases, β k * provides an increasingly better approximation (from below) to α k . To guarantee the same level of approximation via the lower bound α k α k ( n ) Q ( n ) , increasing values of n are required, as k increases. Eventually, computing β k * becomes less expensive than estimating α k ( n ) .

7. A Conjecture on the Asymptotic Behavior of α k

Unlike the previous sections of this paper, the present one is rather speculative and is meant to to take some rather preliminary steps toward the understanding of the asymptotic behavior of α k with k. To focus the exploration, we formulate a specific conjecture, namely that lim k ( 1 α k ) k = c α for some constant c α 1 . Essentially, we are conjecturing that the limit is finite. The bound c α 1 follows from α k 1 1 k (the expected Hamming distance per symbol). The discussion below provides context and motivation for the conjecture, and contemplates the more specific hypothesis that 3 c α 4 .
In the context of the LCS problem, ref. [38] have proven the conjecture, proposed by [39], that lim k γ k k = 2 . As a corollary, we have that, for large k, 1 α k γ k 2 k . However, our intuition is that, although for large n and k we can expect an LCS of length approximately 2 n k , it would be too costly, in terms of insertions and deletions, to align more than O ( n k ) matches, so that, ultimately, for large k, we expect α k 1 c α k .
We tentatively investigate the conjecture numerically, by considering Monte Carlo estimates of the quantity c α , k ( n ) = ( 1 α k ( n ) ) k . Unfortunately, obtaining such estimates with the required precision presents some challenges.
Since we expect values of c α , k ( n ) not much larger than 1, we need the error on ( 1 α k ( n ) ) , hence on α k ( n ) , to be a fraction of 1 / k , a constraint that becomes increasingly stringent as k increases. In order to guarantee a sufficient upper bound on the error, based on Proposition 3 and its corollary Equation (17), the necessary values of n and N quickly become prohibitive, as k increases. However, we suspect that these errors bounds do become rather loose, for large k. More specifically, we hypothesize that, for x , y k n with large k, the standard deviation of d E ( x , y ) / n can be approximated as 1 k n . This is based on the intuition that, for large k, the edit distance behaves similarly to the Hamming distance d H ( x , y ) , whose standard deviation can be easily determined to be n 1 k 1 1 k n k . We have tested this hypothesis by experimentally estimating the standard deviation of d E ( x , y ) / n , for n = 2 18 and k = 2 14 , based on N = 80 independent pairs of random strings. The estimated value turned out to be 0.14 × 10 4 , well in line with our assumption that the standard deviation is approximately 1 k n = 1 2 14 2 18 = 2 16 0.15 × 10 4 .
Table 9 shows estimates of c α , k ( n ) for n = 2 17 , 2 18 , 2 19 , 2 20 and k = 2 7 , 2 8 , , 2 20 . Highlighted in bold face are the entries (33 in number) for which the hypothesized statistical error k 1 k n = k n on c α , k ( n ) is at most 1 4 , that is, k n 16 . We can observe that, where the hypothesized error is small enough, 3 c α , k ( n ) 4 . We remark that, although to cope with the quadratic complexity of the edit distance computation we have considered only one pair of random strings for each ( k , n ) entry in Table 9, the consistency of the numerical value of c α , k ( n ) across the 33 bold entries, obtained from statistically independently samples, does lend some support to the sub-conjecture 3 c α 4 .
Of course, how well c α , k ( n ) approximates c α , k depends on how well α k ( n ) approximates α k . The quality of the latter approximation increases for large k, where the the bound provided by Theorem 2 becomes loose. In fact, putting together various results, we have that
1 M log 2 ( k 1 ) α k α k ( n ) 1 1 k .
We can see that the difference between the last and the first term, hence the difference α k ( n ) α k between the intermediate terms, vanishes when k diverges. The quantitative impact on the difference c α , k c α , k ( n ) remains to be seen, but the relative stability of the bold entries in each column of Table 9 seems compatible with assuming a small impact. Of course, this section remains in the realm of conjectures, which will hopefully provide some motivation for rigorous analysis that may confirm as well as refute them.

8. Conclusions and Further Questions

In this paper, we have explored ways to compute Monte Carlo estimates, upper bounds, and lower bounds to the asymptotic constant characterizing the expected edit distance between random, independent strings. We have presented the theoretical basis for various approaches and used them to obtain numerical results for some alphabet sizes k, which improve over previously known values [1]. However, there is still a significant gap between upper and lower bounds that can be actually computed in a reasonable time. Below, we outline a number of open questions worthy of further investigation.
The approaches proposed here can be extended to the study of other statistical properties of the edit distance for a given length n, e.g., the standard deviation, which has been widely studied in the context of the longest common subsequence. Ultimately, a characterization of the full distribution would be desirable.
The exact rate of convergence q k ( n ) = α k ( n ) α k , or even just its asymptotic behavior, remains to be determined. In particular, we are not aware of any significant lower bound to q k ( n ) to be compared with the upper bound Q ( n ) . Moreover, this upper bound is oblivious to k, whereas the rate of convergence is affected by k, as indicated by Equation (40).
From Proposition 8 and a straightforward analysis of “Hamming scripts”, which use only matches and substitutions, we know that M log 2 k 1 α k 1 k , (where M 2.52 ); what is the exact asymptotic behavior of 1 α k ? We have conjectured that, asymptotically, 1 α k approaches c α / k , for some constant c α 1 ; but whether the conjecture holds, and if so for which value of c α , remains to be seen.
Of mathematical interest, is the question whether α k is a rational or an algebraic number. The answer could depend upon k. The recent work of [19] on the algebraic nature of γ 2 indicates that this line of investigation may lead to uncovering deep combinatorial properties that can shed light on various aspects of the subject, well beyond mere mathematical curiosity.
The analysis of the statistical error could be somewhat improved, if the experimental evidence that the standard deviation of d E ( x , y ) is o ( n ) were corroborated analytically. The dependence upon k could also play a role here.
The complexity of computing, say, the most significant h bits of α k ( n ) remains a wide open question. The only known lower bound is Ω ( log k + log n + h ) , based on the input and output size. It is a far cry from the current upper bound, which is doubly exponential in log n . However, a deeper understanding of the distribution and symmetries of the edit distance is likely to be required before the computation time of α k ( n ) can be significantly improved.
The lower bounds presented in Section 6 are based on upper bounds to the number of optimal scripts of a given cost r. Our counting argument could be refined to take into account some properties of optimal edit scripts. For example, in an optimal script, an insertion cannot immediately precede or follow a deletion (since the same result could be achieved by just one substitution). Furthermore, it would be easy to show that, for many pairs of strings, multiple scripts are counted by our argument. Part of the difficulty with improving script counting comes from the analytical tractability of the resulting combinatorial expressions, which would be far more complicated than Equation (28).
Another potential weakness of our lower bound is that it is derived from a lower bound to ecc ( x ) that must hold for every x k n . If, as n goes to infinity, the fraction of strings with eccentricity significantly smaller than the average were to remain sufficiently high, then the approach would be inherently incapable of yielding tight bounds. On the other hand, preliminary efforts seem to indicate that characterizing the strings with minimum eccentricity is not straightforward. In contrast, it is a relatively simple exercise to prove that the strings of maximum eccentricity are those where all positions contain the same symbol and that their eccentricity equals ( 1 1 k ) n .
In terms of applications, it would be interesting to explore the role of statistical properties of the edit distance in string alignment and other key problems in DNA processing and molecular biology. One motivation is provided by the error profile of reads coming from third generation sequencers (e.g., PacBio), where sequencing errors can be modeled as edit operations. In this context, it would be important to generalize the analysis to non-uniform string distributions, whether defined analytically or from empirical data, such as the distribution of substrings from the human DNA. As briefly discussed in Section 4 and Section 5, the approach we have presented for Monte Carlo estimates and for exact estimates via the Coalesced Dynamic Programming algorithm can easily handle arbitrary symbol distributions, as long as the symbols are statistically independent. The extension of the lower bounds of Section 6 appears less straightforward.
Also of great interest would be to analyze the expected distance between noisy copies of two independent strings, as well as between a string and a noisy copy of itself, when the noise can be modeled in terms of edit operations.
While it is natural to begin investigating questions in the simplest scenarios, which for the present investigation is represented by strings with independent symbols, in several application contexts, the assumption of independence is not satisfied. Hence, future work should go in the direction of removing this assumption. However, while the experimental evidence may clearly indicate that some sequences exhibit a non trivial degree of intersymbol dependence, for example because they are compressible, such dependence has not been satisfactorily captured by well defined stochastic models. Therefore, it is likely that, in the near future, dependent models will be studied more because they have a well understood structure (say, Markov models) than because the are known to capture natural phenomena. Finding the right models, perhaps based on variants of transformers, is probably the main key step, to enable a better connection between theory and applications.

Author Contributions

Conceptualization, G.B. and M.S.; methodology, G.B. and M.S.; software, M.S.; validation, G.B. and M.S.; formal analysis, G.B. and M.S.; writing—original draft preparation, G.B. and M.S.; writing—review and editing, G.B. and M.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded in part by the European Union through MUR “National Center for HPC, Big Data, and Quantum Computing”, CN00000013 (PNRR); by MUR, the Italian Ministry of University and Research, under PRIN Project n. 2022TS4Y3N-EXPAND: scalable algorithms for EXPloratory Analyses of heterogeneous and dynamic Networked Data; by the University of Padova, Project CPGA3 Parallel and Hierarchical Computing: Architectures, Algorithms, and Applications; and by IBM under a Shared University Research Award.

Data Availability Statement

Software and data can be found on the following GitLab repository https://gitlab.com/skimmy/average-edit-distance (accessed on 29 May 2026).

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Ganguly, S.; Mossel, E.; Racz, M.Z. Sequence assembly from corrupted shotgun reads. arXiv 2016, arXiv:1601.07086. [Google Scholar]
  2. Rubinstein, A. Hardness of Approximate Nearest Neighbor Search. In STOC 2018: Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing; Association for Computing Machinery: New York, NY, USA, 2018; pp. 1260–1268. [Google Scholar] [CrossRef]
  3. Comin, M.; Schimd, M. Assembly-free genome comparison based on next-generation sequencing reads and variable length patterns. BMC Bioinform. 2014, 15, S1. [Google Scholar] [CrossRef] [PubMed]
  4. Weirather, J.L.; de Cesare, M.; Wang, Y.; Piazza, P.; Sebastiano, V.; Wang, X.J.; Buck, D.; Au, K.F. Comprehensive comparison of Pacific Biosciences and Oxford Nanopore Technologies and their applications to transcriptome analysis. F1000Research 2017, 6, 100. [Google Scholar] [CrossRef] [PubMed]
  5. Chvátal, V.; Sankoff, D. Longest common subsequences of two random sequences. J. Appl. Probab. 1975, 12, 306–315. [Google Scholar] [CrossRef]
  6. Steele, J.M. Probability Theory and Combinatorial Optimization; SIAM: Philadelphia, PA, USA, 1997. [Google Scholar] [CrossRef]
  7. Schimd, M.; Bilardi, G. Bounds and estimates on the average edit distance. In Proceedings of the String Processing and Information Retrieval; Brisaboa, N.R., Puglisi, S.J., Eds.; Springer: Cham, Switzerland, 2019; pp. 91–106. [Google Scholar] [CrossRef]
  8. Bilardi, G.; Schimd, M. Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance. arXiv 2022, arXiv:2211.07644. [Google Scholar]
  9. Rosenfeld, M. Upper bounds on the average edit distance between two random strings. arXiv 2024, arXiv:2407.18113. [Google Scholar] [CrossRef]
  10. Bundschuh, R. High precision simulations of the longest common subsequence problem. Eur. Phys. J. B-Condens. Matter Complex Syst. 2001, 22, 533–541. [Google Scholar] [CrossRef]
  11. Dancík, V. Expected Length of Longest Common Subsequences. Ph.D. Thesis, University of Warwick, Coventry, UK, 1994. [Google Scholar]
  12. Ning, K.; Choi, K.P. Systematic assessment of the expected length, variance and distribution of Longest Common Subsequences. arXiv 2013, arXiv:1306.4253. [Google Scholar]
  13. Bukh, B.; Cox, C. Periodic words, common subsequences and frogs. Ann. Appl. Probab. 2022, 32, 1295–1332. [Google Scholar] [CrossRef]
  14. Lueker, G.S. Improved Bounds on the Average Length of Longest Common Subsequences. J. ACM 2009, 56, 17. [Google Scholar] [CrossRef]
  15. Heineman, G.T.; Miller, C.; Reichman, D.; Salls, A.; Sárközy, G.; Soiffer, D. Improved Lower Bounds on the Expected Length of Longest Common Subsequences. arXiv 2024, arXiv:2407.10925. [Google Scholar]
  16. Baeza-Yates, R.A.; Gavaldá, R.; Navarro, G.; Scheihing, R. Bounding the Expected Length of Longest Common Subsequences and Forests. Theory Comput. Syst. 1999, 32, 435–452. [Google Scholar] [CrossRef]
  17. Alexander, K.S. The Rate of Convergence of the Mean Length of the Longest Common Subsequence. Ann. Appl. Probab. 1994, 4, 1074–1082. [Google Scholar] [CrossRef]
  18. Lember, J.; Matzinger, H.; Torres, F. The rate of the convergence of the mean score in random sequence comparison. Ann. Appl. Probab. 2012, 22, 1046–1058. [Google Scholar] [CrossRef]
  19. Tiskin, A. The Chvátal–Sankoff problem: Understanding random string comparison through stochastic processes. In Proceedings of the Representation Theory, Dynamical Systems, Combinatorial Methods, Part XXXIV. Zapiski Nauchnykh Seminarov POMI; Vershik, A.M., Vassiliev, N.N., Eds.; Springer: Berlin/Heidelberg, Germany, 2022; pp. 191–224. [Google Scholar]
  20. Masek, W.J.; Paterson, M.S. A faster algorithm computing string edit distances. J. Comput. Syst. Sci. 1980, 20, 18–31. [Google Scholar] [CrossRef]
  21. Myers, G. A Fast Bit-Vector Algorithm for Approximate String Matching Based on Dynamic Programming. J. ACM 1999, 46, 395–415. [Google Scholar] [CrossRef]
  22. Hirschberg, D.S. A Linear Space Algorithm for Computing Maximal Common Subsequences. Commun. ACM 1975, 18, 341–343. [Google Scholar] [CrossRef]
  23. Kundeti, V.; Rajasekaran, S. Extending the four Russian algorithm to compute the edit script in linear space. In Proceedings of the International Conference on Computational Science; Bubak, M., van Albada, G.D., Dongarra, J., Sloot, P.M.A., Eds.; Springer: Berlin/Heidelberg, Germany, 2008; pp. 893–902. [Google Scholar] [CrossRef]
  24. Abboud, A.; Backurs, A.; Williams, V.V. Tight Hardness Results for LCS and Other Sequence Similarity Measures. In Proceedings of the 2015 IEEE 56th Annual Symposium on Foundations of Computer Science; IEEE: Piscataway, NJ, USA, 2015; pp. 59–78. [Google Scholar] [CrossRef]
  25. Backurs, A.; Indyk, P. Edit Distance Cannot Be Computed in Strongly Subquadratic Time (Unless SETH is False). In STOC ’15: Proceedings of the Forty-Seventh Annual ACM Symposium on Theory of Computing. Association for Computing Machinery; Association for Computing Machinery: New York, NY, USA, 2015; pp. 51–58. [Google Scholar] [CrossRef]
  26. Ukkonen, E. Algorithms for approximate string matching. Inf. Control 1985, 64, 100–118. [Google Scholar] [CrossRef]
  27. Landau, G.M.; Myers, E.W.; Schmidt, J.P. Incremental String Comparison. SIAM J. Comput. 1998, 27, 557–582. [Google Scholar] [CrossRef]
  28. Andoni, A.; Krauthgamer, R.; Onak, K. Polylogarithmic Approximation for Edit Distance and the Asymmetric Query Complexity. In Proceedings of the 2010 IEEE 51st Annual Symposium on Foundations of Computer Science; IEEE: Piscataway, NJ, USA, 2010; pp. 377–386. [Google Scholar] [CrossRef]
  29. Chakraborty, D.; Das, D.; Goldenberg, E.; Koucky, M.; Saks, M. Approximating Edit Distance within Constant Factor in Truly Sub-Quadratic Time. In Proceedings of the 2018 IEEE 59th Annual Symposium on Foundations of Computer Science; IEEE: Piscataway, NJ, USA, 2018; pp. 979–990. [Google Scholar] [CrossRef]
  30. Chakraborty, D.; Das, D.; Goldenberg, E.; Kouckỳ, M.; Saks, M. Approximating edit distance within constant factor in truly sub-quadratic time. J. ACM 2020, 67, 36. [Google Scholar] [CrossRef]
  31. Rubinstein, A.; Song, Z. Reducing approximate Longest Common Subsequence to approximate Edit Distance. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms (SODA); SIAM: Philadelphia, PA, USA, 2020; pp. 1591–1600. [Google Scholar] [CrossRef]
  32. Calvo-Zaragoza, J.; Oncina, J.; de la Higuera, C. Computing the Expected Edit Distance from a String to a Probabilistic Finite-State Automaton. Int. J. Found. Comput. Sci. 2017, 28, 603–621. [Google Scholar] [CrossRef]
  33. Boche, H.; Böck, Y.; Deppe, C. On the Effectiveness of Fekete’s Lemma in Information Theory. In Proceedings of the 2020 IEEE Information Theory Workshop (ITW); IEEE: Piscataway, NJ, USA, 2021; pp. 1–5. [Google Scholar] [CrossRef]
  34. Spencer, J. Asymptopia; American Mathematical Society: Providence, RI, USA, 2014. [Google Scholar] [CrossRef]
  35. McDiarmid, C. On the method of bounded differences. Surv. Comb. 1989, 141, 148–188. [Google Scholar] [CrossRef]
  36. Bhardwaj, V.; Pevzner, P.A.; Rashtchian, C.; Safonova, Y. Trace Reconstruction Problems in Computational Biology. IEEE Trans. Inf. Theory 2021, 67, 3295–3314. [Google Scholar] [CrossRef] [PubMed]
  37. Majithia, J.C.; Levan, D. A note on base-2 logarithm computations. Proc. IEEE 1973, 61, 1519–1520. [Google Scholar] [CrossRef]
  38. Kiwi, M.; Loebl, M.; Jiří, M. Expected length of the longest common subsequence for large alphabets. Adv. Math. 2005, 18, 480–498. [Google Scholar] [CrossRef]
  39. Sankoff, D.; Kruskal, J. Common Subsequences and Monotone Subsequences. In Time Warps, String Edits, and Macromolecules: The Theory and Practice of Sequence Comparison; Addison-Wesley Publishing Company: Reading, MA, USA, 1983; pp. 363–365. [Google Scholar]
Figure 1. Comparison between estimates α ˜ 4 ( n , N ) of α k ( n ) (blue dots) and estimates α ^ 4 ( n , N ) of α 4 (orange crosses). For each value, the confidence interval is shown.
Figure 1. Comparison between estimates α ˜ 4 ( n , N ) of α k ( n ) (blue dots) and estimates α ^ 4 ( n , N ) of α 4 (orange crosses). For each value, the confidence interval is shown.
Information 17 00685 g001
Figure 2. Illustration of the proof of Proposition 9.
Figure 2. Illustration of the proof of Proposition 9.
Information 17 00685 g002
Table 1. Comparison of lower bounds to α k obtained in this paper and in previous work. Best known bounds are highlighted in bold face.
Table 1. Comparison of lower bounds to α k obtained in this paper and in previous work. Best known bounds are highlighted in bold face.
kDančíkLuekerGanguly et al. [1]This Work
2 0.162377 0.17372 0.157761 0.170552
3 0.234197 - 0.265028 0.283660
4 0.291764 - 0.338322 0.359783
5 0.335572 - 0.392040 0.415173
6 0.370684 - 0.433508 0.457766
7 0.399816 - 0.466732 0.491836
8 0.424593 - 0.494136 0.519901
16-- 0.616273 0.644758
32-- 0.708537 0.738677
Table 2. Summary of numerical results obtained applying the methodologies presented in this paper. For various sizes k, the table shows an interval guaranteed to contain α k and an interval containing α k with confidence 99.9 % . The fact that the latter is considerably narrower than the former is due to the difficulty of deriving tight guaranteed bounds.
Table 2. Summary of numerical results obtained applying the methodologies presented in this paper. For various sizes k, the table shows an interval guaranteed to contain α k and an interval containing α k with confidence 99.9 % . The fact that the latter is considerably narrower than the former is due to the difficulty of deriving tight guaranteed bounds.
kGuaranteed Interval 99.9 % Confidence Interval
2 [ 0.17055 , 0.36932 ] [ 0.26108 , 0.28884 ]
3 [ 0.28366 , 0.53426 ] [ 0.40144 , 0.42920 ]
4 [ 0.35978 , 0.63182 ] [ 0.49031 , 0.51807 ]
5 [ 0.41517 , 0.70197 ] [ 0.55289 , 0.58066 ]
6 [ 0.45776 , 0.75149 ] [ 0.60002 , 0.62778 ]
7 [ 0.49183 , 0.79031 ] [ 0.63701 , 0.66477 ]
8 [ 0.51990 , 0.81166 ] [ 0.66694 , 0.69470 ]
16 [ 0.64475 , 0.89554 ] [ 0.79198 , 0.81974 ]
32 [ 0.73867 , 0.96588 ] [ 0.87230 , 0.90007 ]
Table 3. Estimates  e ˜ 4 ( n , N ) of the average edit distance and α ˜ 4 ( n , N ) = 1 n e ˜ 4 ( n , N ) of the average distance per symbol α 4 ( n ) , for various string lengths n, based on N = 2 39 / n 2 samples. The last column shows the confidence intervals for α 4 ( n ) corresponding to confidence level 99.9 % . S ˜ 4 ( n , N ) is the sample standard deviation of the single-pair distance.
Table 3. Estimates  e ˜ 4 ( n , N ) of the average edit distance and α ˜ 4 ( n , N ) = 1 n e ˜ 4 ( n , N ) of the average distance per symbol α 4 ( n ) , for various string lengths n, based on N = 2 39 / n 2 samples. The last column shows the confidence intervals for α 4 ( n ) corresponding to confidence level 99.9 % . S ˜ 4 ( n , N ) is the sample standard deviation of the single-pair distance.
nN Δ 99.9 % ( n , N ) e ˜ 4 ( n , N ) S ˜ 4 ( n , N ) α ˜ 4 ( n , N ) 99.9 % Conf. Int.
2 8 2 23 0.59 × 10 4 138.10 3.838 0.53946 [ 0.53940 , 0.53953 ]
2 9 2 21 0.84 × 10 4 272.10 4.920 0.53144 [ 0.53135 , 0.53153 ]
2 10 2 19 0.12 × 10 3 538.77 6.307 0.52614 [ 0.52602 , 0.52626 ]
2 11 2 17 0.17 × 10 3 1070.4 8.146 0.52263 [ 0.52246 , 0.52280 ]
2 12 2 15 0.24 × 10 3 2131.5 10.56 0.52039 [ 0.52015 , 0.52063 ]
2 13 2 13 0.34 × 10 3 4250.9 13.62 0.51891 [ 0.51857 , 0.51925 ]
2 14 2 11 0.48 × 10 3 8487.0 17.71 0.51801 [ 0.51753 , 0.51849 ]
2 15 2 9 0.67 × 10 3 16,954 24.98 0.51739 [ 0.51671 , 0.51807 ]
2 16 2 7 0.95 × 10 3 33,884 29.12 0.51704 [ 0.51608 , 0.51799 ]
2 17 2 5 0.13 × 10 2 67,734 38.85 0.51677 [ 0.51542 , 0.51812 ]
2 18 2 3 0.19 × 10 2 135,450 62.94 0.51670 [ 0.51479 , 0.51861 ]
Table 4. Estimates e ˜ k ( n , N ) of the average edit distance and α ˜ k ( n , N ) = 1 n e ˜ k ( n , N ) of the average distance per symbol α k ( n ) , for various alphabet sizes k, based on N = 2 9 samples of pairs of strings with length n = 2 15 . The confidence radius is Δ 99.9 % ( n , N ) = Δ 99.9 % ( 2 15 , 2 9 ) 0.67 × 10 3 ; the corresponding confidence intervals for α k ( n ) are given in the last column. S ˜ k ( n , N ) is the sample standard deviation of the single-pair distance.
Table 4. Estimates e ˜ k ( n , N ) of the average edit distance and α ˜ k ( n , N ) = 1 n e ˜ k ( n , N ) of the average distance per symbol α k ( n ) , for various alphabet sizes k, based on N = 2 9 samples of pairs of strings with length n = 2 15 . The confidence radius is Δ 99.9 % ( n , N ) = Δ 99.9 % ( 2 15 , 2 9 ) 0.67 × 10 3 ; the corresponding confidence intervals for α k ( n ) are given in the last column. S ˜ k ( n , N ) is the sample standard deviation of the single-pair distance.
k e ˜ k ( n , N ) S ˜ k ( n , N ) α ˜ k ( n , N ) 99.9 % Conf. Int.
2 9442.6 26.04 0.28817 [ 0.28749 , 0.28884 ]
314,042 24.88 0.42852 [ 0.42784 , 0.42920 ]
416,954 24.98 0.51739 [ 0.51671 , 0.51807 ]
519,005 22.78 0.57998 [ 0.57930 , 0.58066 ]
620,549 22.00 0.62710 [ 0.62642 , 0.62778 ]
721,761 21.05 0.66409 [ 0.66341 , 0.66477 ]
822,742 20.15 0.69402 [ 0.69334 , 0.69470 ]
1626,839 16.38 0.81906 [ 0.81838 , 0.81974 ]
3229,471 14.10 0.89939 [ 0.89871 , 0.90007 ]
Table 5. Estimates α ^ 4 ( n , N ) of α 4 with confidence intervals for various string lengths n, based on N = 2 39 / n 2 samples (so that each estimate takes approximately the same computation time). I 4 ( n , N , Δ ) is the corresponding 99.9 % confidence interval for α 4 . The estimates improve with growing n, as witnessed by the decrease of the interval radius R 0.999 ( n , N ) .
Table 5. Estimates α ^ 4 ( n , N ) of α 4 with confidence intervals for various string lengths n, based on N = 2 39 / n 2 samples (so that each estimate takes approximately the same computation time). I 4 ( n , N , Δ ) is the corresponding 99.9 % confidence interval for α 4 . The estimates improve with growing n, as witnessed by the decrease of the interval radius R 0.999 ( n , N ) .
nN R 0.999 ( n , N ) α ^ 4 ( n , N ) I 4 ( n , N , Δ )
2 8 2 23 0.11534 0.42418 [ 0.30884 , 0.53953 ]
2 9 2 21 0.08523 0.44629 [ 0.36105 , 0.53153 ]
2 10 2 19 0.06287 0.46338 [ 0.40051 , 0.52626 ]
2 11 2 17 0.04631 0.47649 [ 0.43075 , 0.52280 ]
2 12 2 15 0.03409 0.48654 [ 0.45244 , 0.52063 ]
2 13 2 13 0.02512 0.49413 [ 0.46900 , 0.51925 ]
2 14 2 11 0.01858 0.49990 [ 0.48132 , 0.51849 ]
2 15 2 9 0.01388 0.50419 [ 0.49031 , 0.51807 ]
2 16 2 7 0.01056 0.50742 [ 0.49685 , 0.51799 ]
2 17 2 5 0.00833 0.50979 [ 0.50145 , 0.51812 ]
2 18 2 3 0.00698 0.51163 [ 0.50465 , 0.51861 ]
Table 6. Estimates of α k for various alphabet sizes k, based on N = 2 9 samples of pairs of string with length n = 2 15 . The radius of the interval I k ( n , N , Δ ) is based on a λ = 0.999 confidence level and is R 0.999 ( 2 15 , 2 9 ) 1.4 × 10 2 , for all values of k.
Table 6. Estimates of α k for various alphabet sizes k, based on N = 2 9 samples of pairs of string with length n = 2 15 . The radius of the interval I k ( n , N , Δ ) is based on a λ = 0.999 confidence level and is R 0.999 ( 2 15 , 2 9 ) 1.4 × 10 2 , for all values of k.
k α ^ k ( n , N ) I k ( n , N , Δ )
2 0.27496 [ 0.26108 , 0.28884 ]
3 0.41532 [ 0.40144 , 0.42920 ]
4 0.50419 [ 0.49031 , 0.51807 ]
5 0.56678 [ 0.55289 , 0.58066 ]
6 0.61390 [ 0.60002 , 0.62778 ]
7 0.65089 [ 0.63701 , 0.66477 ]
8 0.68082 [ 0.66694 , 0.69459 ]
16 0.80586 [ 0.79198 , 0.81974 ]
32 0.88619 [ 0.87230 , 0.90007 ]
Table 7. Values α k ( n ) computed using the Coalesced Dynamic Programming algorithm for various alphabets. The string lengths n k u b ’s have been chosen so that the total time needed to compute α k ( n ) is roughly the same for each k (approximately one week on a machine with 32 cores).
Table 7. Values α k ( n ) computed using the Coalesced Dynamic Programming algorithm for various alphabets. The string lengths n k u b ’s have been chosen so that the total time needed to compute α k ( n ) is roughly the same for each k (approximately one week on a machine with 32 cores).
k n k ub α k ( n k ub )
224 0.36932
317 0.53426
415 0.63182
513 0.70197
612 0.75149
711 0.79031
811 0.81166
1610 0.89554
326 0.96588
Table 8. Lower bound β ¯ k * to α k , for various values of k. With reference to Proposition 13, ϵ = 10 8 , hence the five digits to the right of the decimal point are guaranteed to be the same as those of β k * . The simple 1 1 / k upper bound to α k shows how, for large k, β k * , is quite close to α k .
Table 8. Lower bound β ¯ k * to α k , for various values of k. With reference to Proposition 13, ϵ = 10 8 , hence the five digits to the right of the decimal point are guaranteed to be the same as those of β k * . The simple 1 1 / k upper bound to α k shows how, for large k, β k * , is quite close to α k .
k β ¯ k * 1 1 / k
2 0.17055 0.50000
3 0.28366 0.66667
4 0.35978 0.75000
5 0.41517 0.80000
6 0.45776 0.83333
7 0.49183 0.85714
8 0.51990 0.87500
16 0.64475 0.93750
32 0.73867 0.96875
2 10 0.94359 0.99902
2 20 0.99686 0.99999
2 30 0.99978 0.99999
2 40 0.99998 0.99999
Table 9. Estimates of c α , k ( n ) = ( 1 α k ( n ) ) k , each based on a single random pair ( N = 1 ) generated independently of the other pairs. In bold face are shown the entries of the table where the (hypothesized) standard deviation of the error k / n lies in the interval [ 0.011 , 0.250 ] .
Table 9. Estimates of c α , k ( n ) = ( 1 α k ( n ) ) k , each based on a single random pair ( N = 1 ) generated independently of the other pairs. In bold face are shown the entries of the table where the (hypothesized) standard deviation of the error k / n lies in the interval [ 0.011 , 0.250 ] .
n
k 2 17 2 18 2 19 2 20
2 7 3.553 3.552 3.566 3.581
2 8 3.617 3.608 3.629 3.635
2 9 3.531 3.656 3.658 3.678
2 10 3.570 3.625 3.654 3.669
2 11 3.406 3.516 3.668 3.652
2 12 3.250 3.656 3.625 3.672
2 13 3.000 3.500 3.500 3.703
2 14 3.125 3.250 3.563 3.672
2 15 3.000 3.500 3.750 3.313
2 16 3.500 2.750 3.250 3.125
2 17 3.000 2.000 3.000 3.000
2 18 4.000 4.000 2.000 2.500
2 19 0.000 2.000 2.000 1.500
2 20 0.000 0.000 0.000 0.000
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Bilardi, G.; Schimd, M. Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance. Information 2026, 17, 685. https://doi.org/10.3390/info17070685

AMA Style

Bilardi G, Schimd M. Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance. Information. 2026; 17(7):685. https://doi.org/10.3390/info17070685

Chicago/Turabian Style

Bilardi, Gianfranco, and Michele Schimd. 2026. "Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance" Information 17, no. 7: 685. https://doi.org/10.3390/info17070685

APA Style

Bilardi, G., & Schimd, M. (2026). Computable Bounds and Monte Carlo Estimates of the Expected Edit Distance. Information, 17(7), 685. https://doi.org/10.3390/info17070685

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop