For two N particle systems 0 and 1 with partition function
and
,
from 
get the thermodynamic free energy difference is ![{\displaystyle \Delta F=-k_{B}T\ln(Q_{1}/Q_{0})=-k_{B}T\ln({\frac {\int ds^{N}\exp[-\beta U_{1}(s^{N})]}{\int ds^{N}\exp[-\beta U_{0}(s^{N})]}})}](//wikimedia.org/api/rest_v1/media/math/render/svg/0609baade70017808cdf8055ed4e24fb6fe6c80a)
For every configuration visited during this sampling of system 1 we can compute the potential energy U as a function of the configuration space, and the potential energy difference is

Now construct a probability density of the potential energy from the above equation:

where in
is a configurational part of a partition function

since


now define two functions:

thus that

and
can be obtained by fitting
and 