replaced python's random module with numpy's for performance