added useful tools and functions for various statistical calculations