Efficient variance-reduction transformations for the simulation of a ratio of two means: application to quantum Monte Carlo simulations