# Coding a Percent Chance of Receiving Reward

Hello All,

I am trying to code an experiment where a subject chooses from two shapes to get a reward. Within a trial, Shape 1 always has a 75% chance of yielding a reward and Shape 2 always has a 25% chance of yielding a reward. How can I code my Reward to be presented based on probabilistic chance?

Thanks,
Jessica

Two possibilities come to mind:

1. Each trial, take a sample of size 1 from a list of 4 items, where 3 items are identical and 1 different (e.g., [1, 1, 1, 2]). There is a 75% chance of an identical item being chosen, and a 25% chance of the different one. So, if the participant chooses shape 1, they get a reward if an identical item is the one sampled; and if they choose shape 2, they get a reward if the different item is sampled.
2. Each trial, generate a number from a uniform distribution between 0 and 1. If the participant selects shape 1 and this number is < .75, they get a reward; if the participant selects shape 2 and the number is < .25, they get a reward.

Relevant functions random.sample(); random.uniform().

Thank you!