Polynomial approximations to continuous functions and stochastic compositions