Added noise-generation function for testing purposes.