Effects of random localizing events on matter waves: formalism and examples