Inverse and Forward Problems of Statistical Mechanics: Classical and Quantum Systems