Subroutine uniform sample