initial implementation of moment.

Also added tests. Currently the arguments `w` and `d` only do anything
when `cent`=True.