Monte Carlo sampling of solutions to inverse problems