We have developed a thorough and accurate method of determining anharmonic
free energies, the temperature dependent effective potential technique (TDEP).
It is based on \emph{ab initio} molecular dynamics followed by a mapping onto a
model Hamiltonian that describes the lattice dynamics. The formalism and the
numerical aspects of the technique are described in details. A number of
practical examples are given, and results are presented, which confirm the
usefulness of TDEP within \emph{ab initio} and classical molecular dynamics
frameworks. In particular, we examine from first-principles the behavior of
force constants upon the dynamical stabilization of body centered phase of Zr,
and show that they become more localized. We also calculate phase diagram for
4He modeled with the Aziz \emph{et al.} potential and obtain results which
are in favorable agreement both with respect to experiment and established
techniques