The Algorithms Behind Probabilistic Programming