Maximum-likelihood estimation for nuclear magnetic resonance spectroscopy