Monte Carlo simulation of the inelastic scattering of electrons and positrons using optical-data models