Calculation of Free Energy from the Internal-Energy Distribution Function