fixed bug in random_sampling where there was an old reference to 'n' instead of 'N'