Static Analysis of Probabilistic Programs: An Algebraic Approach