Example to clarify last commit.

You would call downsample like this for just a mean with size 3:

downsample(raw, mean, 3)

or like this for weighted with size 3:

downsample(raw, weighted3, 3)

or you could get fancy and do stuff like this:

downsample(raw, lambda p: weighted([1, 5, 1], p), 3)

to specify the weights inline