Bayesian Methods in Cosmology: Foundations and algorithms