Gravar-mail: Surface excitations in electron spectroscopy. Part I: dielectric formalism and Monte Carlo algorithm