Application of a random-walk method for stresses in polycrystalline metals