Misc useful functions for statistics
