The Statues algorithm is a new probabilistic inference algorithm that gives exact results in the scope of discrete random variables. This algorithm calculates the marginal probability distributions on graphical models defined as directed acyclic graphs. These models are made up of five primitives that allow expressing, in particular, conditioning, joint probability distributions, Bayesian networks, discrete Markov chains and probabilistic arithmetic. The Statues algorithm relies on an original technique based on the generator construct, a special form of coroutine. This new algorithm aims to promote both efficiency and scope of application. This makes it valuable regarding other probabilistic inference approaches, especially in the field of probabilistic programming.