Statistics Functions

Implement functions for statistics.