# Distinct Elements

Consider the following problem of counting distinct elements: Suppose that $\Omega$ is a sufficiently large universe.

• Input: a sequence of (not necessarily distinct) elements $x_1,x_2,\ldots,x_n\in\Omega$;
• Output: an estimation of the total number of distinct elements $z=|\{x_1,x_2,\ldots,x_n\}|$.

A straightforward way of solving this problem is to maintain a dictionary data structure, which costs at least linear ($O(n)$) space. For big data, where $n$ is very large, this is still too expensive. However, due to an information-theoretical argument, linear space is necessary if you want to compute the exact value of $z$.

Our goal is to relax the problem a little bit to significantly reduce the space cost by tolerating approximate answers. The form of approximation we consider is $(\epsilon,\delta)$-estimator.

 $(\epsilon,\delta)$-estimator A random variable $\widehat{Z}$ is an $(\epsilon,\delta)$-estimator of a quantity $z$ if $\Pr[\,(1-\epsilon)z\le \widehat{Z}\le (1+\epsilon)z\,]\ge 1-\delta$. $\widehat{Z}$ is said to be an unbiased estimator of $z$ if $\mathbb{E}[\widehat{Z}]=z$.

Usually $\epsilon$ is called approximation error and $\delta$ is called confidence error.

We now present an elegant algorithm introduced by Flajolet and Martin in 1984. The algorithm can be implemented in data stream model: The input elements $x_1,x_2,\ldots,x_n$ is presented to the algorithm one at a time, where the size of data $n$ is unknown to the algorithm. The algorithm maintains a value $\widehat{Z}$ which is an $(\epsilon,\delta)$-estimator of the total number of distinct elements $z=|\{x_1,x_2,\ldots,x_n\}|$, using only a small amount of memory space to memorize (with loss) the data set $\{x_1,x_2,\ldots,x_n\}$.

A famous quotation of Flajolet describes the performance of this algorithm as:

"Using only memory equivalent to 5 lines of printed text, you can estimate with a typical accuracy of 5% and in a single pass the total vocabulary of Shakespeare."


## An estimator by hashing

Suppose that we can access to an idealized random hash function $h:\Omega\to[0,1]$ which is uniformly distributed over all mappings from the universe $\Omega$ to unit interval $[0,1]$.

Recall that the input sequence $x_1,x_2,\ldots,x_n\in\Omega$ consists of $z=|\{x_1,x_2,\ldots,x_n\}|$ distinct elements. These elements are mapped by the random function $h$ to $z$ hash values uniformly and independently distributed in $[0,1]$. We could maintain these hash values instead of the original elements, but this would still be too expensive because in the worst case we still have up to $n$ distinct values to maintain. However, due to the idealized random hash function, the unit interval $[0,1]$ will be partitioned into $z+1$ subintervals by these $z$ uniform and independent hash values. The typical length of the subinterval gives an estimation of the number $z$.

 Proposition $\mathbb{E}\left[\min_{1\le i\le n}h(x_i)\right]=\frac{1}{z+1}$.
Proof.
 The input sequence $x_1,x_2,\ldots,x_n\in\Omega$ consisting of $z$ distinct elements are mapped to $z$ random hash values uniformly and independently distributed in $[0,1]$. These $z$ hash values partition the unit interval $[0,1]$ into $z+1$ subintervals $[0,v_1],[v_1,v_2],[v_2,v_3]\ldots,[v_{z-1},v_z],[v_z,1]$, where $v_i$ denotes the $i$-th smallest value among all hash values $\{h(x_1),h(x_2),\ldots,h(x_n)\}$. Clearly we have $v_1=\min_{1\le i\le n}h(x_i)$. Meanwhile, since all hash values are uniformly and independently distributed in $[0,1]$, the lengths of all subintervals $v_1, v_2-v_1, v_3-v_2,\ldots, v_z-v_{z-1}, 1-v_z$ are identically distributed. By symmetry, they have the same expectation, therefore $(z+1)\mathbb{E}[v_1]= \mathbb{E}[v_1]+\sum_{i=1}^{z-1}\mathbb{E}[v_{i+1}-v_i]+\mathbb{E}[1-v_z] =\mathbb{E}\left[v_1+(v_2-v_1)+(v_3-v_2)+\cdots+(v_{z}-v_{z-1})+1-v_z\right] =1,$ which implies that $\mathbb{E}\left[\min_{1\le i\le n}h(x_i)\right]=\mathbb{E}[v_1]=\frac{1}{z+1}$.
$\square$

The quantity $\min_{1\le i\le n}h(x_i)$ can be computed with small space cost (for storing the current smallest hash value) by scan the input sequence in a single pass. Because as we proved its expectation is $\frac{1}{z+1}$, the smallest hash value $Y=\min_{1\le i\le n}h(x_i)$ gives an unbiased estimator for $\frac{1}{z+1}$. However, $\frac{1}{Y}-1$ is not necessarily a good estimator for $z$. Actually, it is a rather poor estimator. Consider for example when $z=1$, all input elements are the same. In this case, there is only one hash value and $Y=\min_{1\le i\le n}h(x_i)$ is distributed uniformly over $[0,1]$, thus $\frac{1}{Y}-1$ fails to be close enough to the correct answer 1 with high probability.

## Flajolet-Martin algorithm

The reason that the above estimator of a single hash function performs poorly is that the unbiased estimator $\min_{1\le i\le n}h(x_i)$ has large variance. So a natural way to reduce this variance is to have multiple independent hash functions and take the average. This is precisely what Flajolet-Martin algorithm does.

Suppose that we can access to $k$ independent random hash functions $h_1,h_2,\ldots,h_k$, where each $h_j:\Omega\to[0,1]$ is uniformly and independently distributed over all functions mapping $\Omega$ to $[0,1]$. Here $k$ is a parameter to be fixed by the desired approximation error $\epsilon$ and confidence error $\delta$. The Flajolet-Martin algorithm is given by the following pseudocode.

 Flajolet-Martin algorithm (Flajolet and Martin 1984) Suppose that $h_1,h_2,\ldots,h_k:\Omega\to[0,1]$ are $k$ uniform and independent random hash functions, where $k$ is a parameter to be fixed later. Scan the input sequence $x_1,x_2,\ldots,x_n\in\Omega$ in a single pass to compute: $Y_j=\min_{1\le i\le n}h_j(x_i)$ for every $j=1,2,\ldots,k$; average value $\overline{Y}=\frac{1}{k}\sum_{j=1}^kY_j$; return $\widehat{Z}=\frac{1}{\overline{Y}}-1$ as the estimator.

The algorithm is easy to implement in data stream model, with a space cost of storing $k$ hash values. The following theorem guarantees that the algorithm returns an $(\epsilon,\delta)$-estimator of the total number of distinct elements for a suitable $k=O\left(\frac{1}{\epsilon^2\delta}\right)$.

 Theorem For any $\epsilon,\delta\lt 1/2$, if $k\ge\left\lceil\frac{4}{\epsilon^2\delta}\right\rceil$ then the output $\widehat{Z}$ always gives an $(\epsilon,\delta)$-estimator of the correct answer $z$.

In the following we prove this main theorem for Flajolet-Martin algorithm.

An obstacle to analyze the estimator $\widehat{Z}=\frac{1}{\overline{Y}}-1$ is that it is a nonlinear function of $\overline{Y}$ who is easier to analyze. Nevertheless, we observe that $\widehat{Z}$ is an $(\epsilon,\delta)$-estimator of $z$ as long as $\overline{Y}$ is an $(\epsilon/2,\delta)$-estimator of $\frac{1}{z+1}$. This can be deduced by just verifying the following:

$\frac{1-\epsilon/2}{z+1}\le \overline{Y}\le \frac{1+\epsilon/2}{z+1} \implies (1-\epsilon)z\le\frac{1}{\overline{Y}}-1\le (1+\epsilon)z$,

for $\epsilon\lt \frac{1}{2}$. Therefore,

$\Pr\left[\,(1-\epsilon)z\le \widehat{Z} \le (1+\epsilon)z\,\right]\ge \Pr\left[\,\frac{1-\epsilon/2}{z+1}\le \overline{Y}\le \frac{1+\epsilon/2}{z+1}\,\right] =\Pr\left[\,\left|\overline{Y}-\frac{1}{z+1}\right|\le \frac{\epsilon/2}{z+1}\,\right]$.

It is then sufficient to show that $\Pr\left[\,\left|\overline{Y}-\frac{1}{z+1}\right|\le \frac{\epsilon/2}{z+1}\,\right]\ge 1-\delta$ for proving the main theorem above. We will see that this is equivalent to show the concentration inequality

$\Pr\left[\,\left|\overline{Y}-\mathbb{E}\left[\overline{Y}\right]\right|\le \frac{\epsilon/2}{z+1}\,\right]\ge 1-\delta\quad\qquad({\color{red}*})$.
 Lemma The followings hold for each $Y_j$, $j=1,2\ldots,k$, and $\overline{Y}=\frac{1}{k}\sum_{j=1}^kY_j$: $\mathbb{E}\left[\overline{Y}\right]=\mathbb{E}\left[Y_j\right]=\frac{1}{z+1}$; $\mathbf{Var}\left[Y_j\right]\le\frac{1}{(z+1)^2}$, and consequently $\mathbf{Var}\left[\overline{Y}\right]\le\frac{1}{k(z+1)^2}$.
Proof.
 As in the case of single hash function, by symmetry it holds that $\mathbb{E}[Y_j]=\frac{1}{z+1}$ for every $j=1,2,\ldots,k$. Therefore, $\mathbb{E}\left[\overline{Y}\right]=\frac{1}{k}\sum_{j=1}^k\mathbb{E}[Y_j]=\frac{1}{z+1}$. Recall that each $Y_j$ is the minimum of $z$ random hash values uniformly and independently distributed over $[0,1]$. By geometry probability, it holds that for any $y\in[0,1]$, $\Pr[Y_j\gt y]=(1-y)^z$, which means $\Pr[Y_j\le y]=1-(1-y)^z$. Taking the derivative with respect to $y$, we obtain the probability density function of random variable $Y_j$, which is $z(1-y)^{z-1}$. We then compute the second moment. $\mathbb{E}[Y_j^2]=\int^{1}_0y^2z(1-y)^{z-1}\,\mathrm{d}y=\frac{2}{(z+1)(z+2)}$. The variance is bounded as $\mathbf{Var}\left[Y_j\right]=\mathbb{E}\left[Y_j^2\right]-\mathbb{E}\left[Y_j\right]^2=\frac{2}{(z+1)(z+2)}-\frac{1}{(z+1)^2}\le\frac{1}{(z+1)^2}$. Due to the (pairwise) independence between $Y_j$'s, $\mathbf{Var}\left[\overline{Y}\right]=\mathbf{Var}\left[\frac{1}{k}\sum_{j=1}^kY_j\right]=\frac{1}{k^2}\sum_{j=1}^k\mathbf{Var}\left[Y_j\right]\le \frac{1}{k(z+1)^2}$.
$\square$

We resume to prove the inequality $({\color{red}*})$. By Chebyshev's inequality, it holds that

$\Pr\left[\,\left|\overline{Y}-\mathbb{E}\left[\overline{Y}\right]\right|\gt \frac{\epsilon/2}{z+1}\,\right] \le\frac{4}{\epsilon^2}(z+1)^2\mathbf{Var}\left[\overline{Y}\right] \le\frac{4}{\epsilon^2k}$.

When $k\ge\left\lceil\frac{4}{\epsilon^2\delta}\right\rceil$, this probability is at most $\delta$. The inequality $({\color{red}*})$ is proved. As we discussed above, this proves the above main theorem for Flajolet-Martin algorithm.

## Uniform Hash Assumption (UHA)

In above we assume we can access to idealized random hash functions $h:\Omega\to[0,1]$ with real values. With a more careful calculation, one can show the same performance guarantee for hash functions with discrete values as $h:\Omega\to[M]$ where $M=\mathrm{poly}(n)$, that is, the hash values are strings of $O(\log n)$ bits.

Even with such improved analysis, a uniform random discrete function in form of $h:[N]\to[M]$ is not really efficient to store or to compute. By an information-theretical argument, it takes at least $\Omega(N\log M)$ bits to represent such a random hash function because this is the entropy of such uniform random function.

For the convenience of analysis, it is common to assume the following Uniform Hash Assumption (UHA) also known as Simple Uniform Hash Assumption (SUHA).

 Uniform Hash Assumption (UHA) A uniform random function $h:[N]\rightarrow[M]$ is available and the computation of $h$ is efficient.

# Set Membership

A basic question in Computer Science is:

"$\mbox{Is }x\in S?$"

for a set $S$ and an element $x$. This is the set membership problem.

Formally, given an arbitrary set $S$ of $n$ elements from a universe $\Omega$, we want to use a succinct data structure to represent this set $S$, so that upon each query of any element $x$ from the universe $[N]$, the question of whether $x\in S$ is efficiently answered. The complexity of such data structure is measured in two-fold:

• space cost: size of the data structure to represent a set $S$ of size $n$;
• time cost: time complexity of answering each query by accessing to the data structure.

Suppose that the universe $\Omega$ is of size $N$. Clearly, the membership problem can be solved by a dictionary data structure, e.g.:

• sorted table / balanced search tree: with space cost $O(n\log N)$ bits and time cost $O(\log n)$;
• perfect hashing of Fredman, Komlós & Szemerédi: with space cost $O(n\log N)$ bits and time cost $O(1)$.

Note that $\log{N\choose n}=\Theta\left(n\log \frac{N}{n}\right)$ is the entropy of sets $S$ of $n$ elements from a universe $\Omega$ of size $N$. Therefore it is necessary to use so many bits to represent a set without losing any information. Nevertheless, we can do better than this if we use a loss representation of the input set $S$ and tolerate a bounded error in answering queries. Such lossy representation of data is sometimes called a sketch.

## Bloom filter

The Bloom filter is a space-efficient hash table that solves the approximate membership problem with one-sided error (false positive).

Given a set $S$ of $n$ elements from a universe $\Omega$, a Bloom filter consists of an array $A$ of $cn$ bits, and $k$ hash functions $h_1,h_2,\ldots,h_k$ map $\Omega$ to $[cn]$, where both $c$ and $k$ are parameters that we can try to optimize later.

As before, we assume the Uniform Hash Assumption (UHA): $h_1,h_2,\ldots,h_k$ are mutually independent hash function where each $h_i$ is a uniform random hash function $h_i:\Omega\to[cn]$.

The Bloom filter works as follows:

 Bloom filter (Bloom 1970) Suppose $h_1,h_2,\ldots,h_k:\Omega\to[cn]$ are uniform and independent random hash functions. Data structure construction: Given a set $S\subset\Omega$ of size $n=|S|$, the data structure is a Boolean array $A$ of $cn$ bits constructed as initialize all $cn$ bits of the Boolean array $A$ to 0; for each $x\in S$, let $A[h_i(x)]=1$ for all $1\le i\le k$. Query resolution: Upon each query of an arbitrary $x\in\Omega$, answer "yes" if $A[h_i(x)]=1$ for all $1\le i\le k$ and "no" if otherwise.

The Boolean array is our data structure, whose size is $cn$ bits. With Uniform Hash Assumption (UHA), the time cost of the data structure for answering each query is $O(k)$.

When the answer returned by the algorithm is "no", it holds that $A[h_i(x)]=0$ for some $1\le i\le k$, in which case the query $x$ must not belong to the set $S$. Thus, the Bloom filter has no false negatives.

On the other hand, when the answer returned by the algorithm is "yes", $A[h_i(x)]=1$ for all $1\le i\le k$. It is still possible for some $x\not\in S$ that all bits $A[h_i(x)]$ are set by elements in $S$. We want to bound such false positive, that is, the following probability for an $x\not\in S$:

$\Pr[\,\forall 1\le i\le k, A[h_i(x)]=1\,]$,

which by independence between different hash functions and by symmetry is equal to:

$\Pr[\, A[h_1(x)]=1\,]^k=(1-\Pr[\, A[h_1(x)]=0\,])^k$.

For an element $x\not\in S$, its hash value $h_1(x)$ is independent of all hash values $h_i(y)$ for all $1\le i\le k$ and all $y\in S$. This is due to the Uniform Hash Assumption. The hash value $h_1(x)$ of $x\not\in S$ is then independent of the content of the array $A$. Therefore, the probability of this position $A[h_1(x)]$ missed by all $kn$ updates to the Boolean array $A$ caused by all $n$ elements in $S$ is:

$\Pr[\, A[h_1(x)]=0\,]=\left(1-\frac{1}{cn}\right)^{kn}\approx e^{-k/c}.$

Putting everything together, for any $x\not\in S$, the false positive is bounded as:

\begin{align} \Pr[\,\text{wrongly answer ''yes''}\,] &=\Pr[\,\forall 1\le i\le k, A[h_i(x)]=1\,]\\ &=\Pr[\, A[h_1(x)]=1\,]^k=(1-\Pr[\, A[h_1(x)]=0\,])^k\\ &=\left(1-\left(1-\frac{1}{cn}\right)^{kn}\right)^k\\ &\approx \left(1- e^{-k/c}\right)^k \end{align}

which is $(0.6185)^c$ when $k=c\ln 2$.

Bloom filter solves the membership query with a small constant error of false positives using a data structure of $O(n)$ bits which answers each query with $O(1)$ time cost.

# Frequency Estimation

Suppose that $\Omega$ is the data universe. The frequency estimation problem is defined as follows.

• Data: a sequence of (not necessarily distinct) elements $x_1,x_2,\ldots,x_n\in\Omega$;
• Query: an element $x\in\Omega$;
• Output: an estimation $\hat{f}_x$ of the frequency $f_x\triangleq|\{i\mid x_i=x\}|$ of $x$ in input data.

We still want to give an algorithm in the data stream model: the algorithm scan the input sequence $x_1,x_2,\ldots,x_n$ to construct a succinct data structure, such that upon each query of $x\in\Omega$, the algorithm returns an estimation of the frequency $f_x$.

Clearly this problem can always be solved by storing all appeared distinct elements along with their frequencies. However, the space cost of this straightforward solution is rather high. Instead, we want to use a lossy representation (a sketch) of input data which uses significantly less space but can still answer queries with tolarable accuracy.

Formally, upon each query of $x\in\Omega$, the algorithm should return an answer $\hat{f}_x$ satisfying:

$\Pr\left[\,\left|\hat{f}_x-f_x\right|\le \epsilon n\,\right]\ge 1-\delta$.

Note that this notion of approximation is with bounded additive error which is weaker than the notion of $(\epsilon,\delta)$-estimator, whose error bound is multiplicative.

With such weak accuracy guarantee, its is possible to give a succinct data structure whose size is determined only by the error bounds $\epsilon$ and $\delta$ but independent of $n$, because only the frequencies of those heavy hitters (elements $x$ with high frequencies $f_x\gt \epsilon n$) need to be memorized, and there are at most $1/\epsilon$ many such heavy hitters.

## Count-min sketch

The count-min sketch given by Cormode and Muthukrishnan is an elegant data structure for frequency estimation.

The data structure is a two-dimensional $k\times m$ integer array, where $k$ and $m$ are two parameters to be determined by the error bounds $\epsilon$ and $\delta$. We still adopt the Uniform Hash Assumption to assume that we have access to $k$ mutually independent uniform random hash functions $h_1,h_2,\ldots,h_k:\Omega\to[m]$.

 Count-min sketch (Cormode and Muthukrishnan 2003) Suppose $h_1,h_2,\ldots,h_k:\Omega\to[m]$ are uniform and independent random hash functions. Data structure construction: Given a sequence $x_1,x_2,\ldots,x_n\in\Omega$, the data structure is a two-dimensional $k\times m$ integer array $CMS[k][m]$ constructed as initialize all entries of $CMS[k][m]$ to 0; for $i=1,2,\ldots,n$, upon receiving $x_i$: for every $1\le j\le k$, evaluate $h_j(x_i)$ and $CMS[j][h_j(x_i)]++$. Query resolution: Upon each query of an arbitrary $x\in\Omega$, return $\hat{f}_x=\min_{1\le j\le k}CMS[j][h_j(x)]$.

It is easy to see that the space cost of count-min sketch is $O(km)$ memory words, or $O(km\log n)$ bits. Each query is answered within time cost $O(k)$, assuming that an evaluation of hash function can be done in unit or constant time. We then analyze the error bounds.

First, it is easy to observe that for any query $x\in\Omega$ and every hash function $1\le j\le k$, it always holds for the corresponding entry in the count-min sketch

$CMS[j][h_j(x)]\ge f_x$,

because the appearances of element $x$ in the input sequence contribute at least $f_x$ to the value of $CMS[j][h_j(x)]$.

Therefore, for any query $x\in\Omega$ it always holds for the answer $\hat{f}_x=\min_{1\le j\le k}CMS[j][h_j(x)]\ge f_x$, which means

$\Pr\left[\,\left|\hat{f}_x- f_x\right|\ge\epsilon n\,\right]=\Pr\left[\,\hat{f}_x- f_x\ge\epsilon n\,\right]=\prod_{j=1}^k\Pr[\,CMS[j][h_j(x)]-f_x\ge\epsilon n\,],\quad\qquad({\color{red}\diamondsuit})$

where the second equation is due to the mutual independence of random hash functions $h_1,h_2,\ldots,h_k$.

It remains to upper bound the probability $\Pr[\,CMS[j][h_j(x)]-f_x\ge\epsilon n\,]$, which can be done by calculating the expectation of $CMS[j][h_j(x)]$.

 Proposition For any $x\in\Omega$ and every $1\le j\le k$, it holds that $\mathbb{E}\left[CMS[j][h_j(x)]\right]\le f_x+\frac{n}{m}$.
Proof.
 The value of $CMS[j][h_j(x)]$ is constituted by the frequency $f_x$ of $x$ and the frequencies $f_y$ of all other elements $y\neq x$ among $x_1,x_2,\ldots,x_n$, thus \begin{align} CMS[j][h_j(x)] &=f_x+\sum_{\scriptstyle y\in\{x_1,\ldots,x_n\}\setminus\{x\}\atop\scriptstyle h_j(y)=h_j(x)} f_y\\ &=f_x+\sum_{y\in\{x_1,\ldots,x_n\}\setminus\{x\}} f_y \cdot I[h_j(y)=h_j(x)] \end{align} where $I[h_j(y)=h_j(x)]$ denotes the Boolean random variable that indicates the occurrence of event $h_j(y)=h_j(x)$. By linearity of expectation, $\mathbb{E}[CMS[j][h_j(x)]]=f_x+\sum_{y\in\{x_1,x_2,\ldots,x_n\}\setminus\{x\}} f_y \cdot \Pr[h_j(y)=h_j(x)]$. Due to Uniform Hash Assumption (UHA), $h_j:\Omega\to[m]$ is a uniform random function. For any $y\neq x$, the probability of hash collision is $\Pr[h_j(y)=h_j(x)]=\frac{1}{m}$. Therefore, \begin{align} \mathbb{E}[CMS[j][h_j(x)]] &=f_x+\frac{1}{m}\sum_{y\in\{x_1,\ldots,x_n\}\setminus\{x\}} f_y \\ &\le f_x+\frac{1}{m}\sum_{y\in\{x_1,\ldots,x_n\}} f_y\\ &=f_x+\frac{n}{m}, \end{align} where the last equation is due to the obvious identity $\sum_{y\in\{x_1,\ldots,x_n\}}f_y=n$.
$\square$

The above proposition shows that for any $x\in\Omega$ and every $1\le j\le k$

$\mathbb{E}\left[CMS[j][h_j(x)]-f_x\right]\le \frac{n}{m}$.

Recall that $CMS[j][h_j(x)]\ge f_x$ always holds, thus $CMS[j][h_j(x)]-f_x$ is a positive random variable. By Markov's inequality, we have

$\Pr[\,CMS[j][h_j(x)]-f_x\ge\epsilon n\,]\le \frac{1}{\epsilon m}$.

Combining with above equation $({\color{red}\diamondsuit})$, we have

$\Pr\left[\,\left|\hat{f}_x- f_x\right|\ge\epsilon n\,\right]=(\Pr[\,CMS[j][h_j(x)]-f_x\ge\epsilon n\,])^k\le \frac{1}{(\epsilon m)^k}$.

By setting $m=\left\lceil\frac{\mathrm{e}}{\epsilon}\right\rceil$ and $k=\left\lceil\ln\frac{1}{\delta}\right\rceil$, the above error probability is bounded as $\frac{1}{(\epsilon m)^k}\le\delta$.

For any positive $\epsilon$ and $\delta$, the count-min sketch gives a data structure of size $O(km)=O\left(\frac{1}{\epsilon}\log\frac{1}{\delta}\right)$ (in memory words) and answering each query $x\in\Omega$ in time $O(k)=O\left(\frac{1}{\epsilon}\right)$ with the following accuracy guarantee:

$\Pr\left[\,\left|\hat{f}_x- f_x\right|\le\epsilon n\,\right]\ge 1-\delta$.