  Translational diffusion coefficients are routinely estimated from molecular
dynamics simulations. Linear fits to mean squared displacement (MSD) curves
have become the de facto standard, from simple liquids to complex
biomacromolecules. Nonlinearities in MSD curves at short times are handled with
a wide variety of ad hoc practices, such as partial and piece-wise fitting of
the data. Here, we present a rigorous framework to obtain reliable estimates of
the diffusion coefficient and its statistical uncertainty. We also assess in a
quantitative manner if the observed dynamics is indeed diffusive. By accounting
for correlations between MSD values at different times, we reduce the
statistical uncertainty of the estimator and thereby increase its efficiency.
With a Kolmogorov-Smirnov test, we check for possible anomalous diffusion. We
provide an easy-to-use Python data analysis script for the estimation of
diffusion coefficients. As an illustration, we apply the formalism to molecular
dynamics simulation data of pure TIP4P-D water and a single ubiquitin protein.
In a companion paper [J. Chem. Phys. XXX, YYYYY (2020)], we demonstrate its
ability to recognize deviations from regular diffusion caused by systematic
errors in a common trajectory "unwrapping" scheme that is implemented in
popular simulation and visualization software.
