extract calc functions to a service

Move Mean/Median/Mode functions to a service.