Python functions for computing basic statistics