Large Deviations Rate Functions for the Empirical Measure: Explicit Formulas and an Application to Monte Carlo