Sample average approximation and stability tests applied to energy system design