Simulation of stochastic systems via polynomial chaos expansions and convex optimization