How to measure the free energy and partition function from atom-atom correlations