math functions to generate random distribution