Random sample in more Pythonic way

compare to #1383