Slightly more efficient, I suspect:
f[n_]:=Mean /@ Partition[RandomChoice[data, 7 n], 7]
Also note (!) the distinction that this needs to be RandomChoice
rather than RandomSample
. RandomChoice
allows random selection from the list of data
without using any of the data
more than once. RandomSample
allows for choosing a random datum more than once. I assume that this is actually what you want.
If you actually want RandomSample
then the original approach posted above by Melvyn would be better, but the lenght of data
must be greater than or equal to 7.