Changed the generating function to use "rowMeans" which is a specific, vectorized version of applying the mean function across rows. This should speed it up a little, though I'm not sure how much.