MCGR: An inverse method for deriving the pair correlation function from the structure factor