A random walk sampling algorithm allows the extraction of the density of states distribution in energy-reaction coordinate space. As a result, the temperature dependences of thermodynamic quantities such as relative energy, entropy, and heat capacity can be calculated using first-principles statistical mechanics. The strategies for optimal convergence of the algorithm and control of its accuracy are proposed. We show that the saturation of the error [Q. Yan and J. J. de Pablo, Phys. Rev. Lett. 90, 035701 (2003); E. Belardinelli and V. D. Pereyra, J. Chem. Phys. 127, 184105 (2007)] is due to the use of histogram flatness as a criterion of convergence. An application of the algorithm to methane dimer hydrophobic interactions is presented. We obtained a quantitatively accurate energy-entropy decomposition of the methane dimer cavity potential. The presented results confirm the previous results, and they provide new information regarding the thermodynamics of hydrophobic interactions. We show that the finite-difference approximation, which is widely used in molecular dynamic simulations for the energy-entropy decomposition of a free energy potential, can lead to a significant error.