  The spectral gap $\gamma$ of a finite, ergodic, and reversible Markov chain
is an important parameter measuring the asymptotic rate of convergence. In
applications, the transition matrix $P$ may be unknown, yet one sample of the
chain up to a fixed time $n$ may be observed. We consider here the problem of
estimating $\gamma$ from this data. Let $\pi$ be the stationary distribution of
$P$, and $\pi_\star = \min_x \pi(x)$. We show that if $n =
\tilde{O}\bigl(\frac{1}{\gamma \pi_\star}\bigr)$, then $\gamma$ can be
estimated to within multiplicative constants with high probability. When $\pi$
is uniform on $d$ states, this matches (up to logarithmic correction) a lower
bound of $\tilde{\Omega}\bigl(\frac{d}{\gamma}\bigr)$ steps required for
precise estimation of $\gamma$. Moreover, we provide the first procedure for
computing a fully data-dependent interval, from a single finite-length
trajectory of the chain, that traps the mixing time $t_{\text{mix}}$ of the
chain at a prescribed confidence level. The interval does not require the
knowledge of any parameters of the chain. This stands in contrast to previous
approaches, which either only provide point estimates, or require a reset
mechanism, or additional prior knowledge. The interval is constructed around
the relaxation time $t_{\text{relax}} = 1/\gamma$, which is strongly related to
the mixing time, and the width of the interval converges to zero roughly at a
$1/\sqrt{n}$ rate, where $n$ is the length of the sample path.
