A new Hedging algorithm and its application to inferring latent random variables