  We demonstrate the application of the Metropolis-Hastings algorithm to
sampling of classical thermal states of one-dimensional Bose-Einstein
quasicondensates in the classical fields approximation, both in untrapped and
harmonically trapped case. The presented algorithm can be easily generalized to
higher dimensions and arbitrary trap geometry. For truncated Wigner simulations
the quantum noise can be added with conventional methods (half a quantum of
energy in every mode). The advantage of the presented method over the usual
analytical and stochastic ones lies in its ability to sample not only from
canonical and grand canonical distributions, but also from the generalized
Gibbs ensemble, which can help to shed new light on thermodynamics of
integrable systems.
