calculate moments