mercredi 17 mai 2023

How to randomly select x number of values from a pool of values in python

For an experiment I am doing, I need to present stimuli (images) on the screen. For the same, I have divided the screen into 6*5 grid which gave me 30 coordinates. I have divided these coordinates into 4 quadrants and a set of points also aligns with the Y-axis. These coordinates based on the different quadrants are:

Q1 = [(94,-328) ,(320,-328), (548,-328), (94,-174), (320,-174), (548,-174)]

Q2 = [(134,288), (360,288), (588,288), (134,134), (360,134), (588,134)]

Q3 = [(-548,134), (-320,134), (-94,134), (-548,288), (-320,288), (-94,288)]

Q4 = [(-588,-328), (-360,-328), (-134,-328), (-588,-174), (-360,-174), (-134,-174)]

Y_axis = [(-568,0), (-340,0), (-114,0), (114,0), (340,0), (568,0)]

In the experiment, in some trials, I have to only present 4 images at 4 locations whereas in another trial I have to present 8 images and 16 images. When presenting images at 4 locations, I need to select one coordinate from each quadrant so that the images are spread across the screen and there is no bias in terms of location on the screen. I will call these 4,8 and 16 set sizes. Under each set size, there are 48 trials.

I need a code that can choose these coordinates randomly from the 30 coordinate values I already have; while ensuring that the coordinates selected by the program are randomly distributed across all 4 quadrants (or Y-axis) of the screen. So, then the code should be in such a way that there are 48 randomly selected choices with 4 coordinates, a selection of 8 coordinates (48 times), and similarly for set size 16.




Aucun commentaire:

Enregistrer un commentaire