rejection sampling python code