python sampling routines