includes optional type-checking for double or NSNumber * on average and sum operations.