-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code to select random conditions is incorrect #3256
Comments
I agree on all the above points, which were clearly expressed 👏 I think those docs have been written in a slight rush (on a relatively rarely-used feature so haven't been noticed) and aren't quite right. Are you comfortable submitting a pull request with the changes? (The docs source is in the repo as well) |
I will try to submit one later today. |
carolfs
added a commit
to carolfs/psychopy
that referenced
this issue
Oct 30, 2020
carolfs
added a commit
to carolfs/psychopy
that referenced
this issue
Oct 30, 2020
Merged
Merged
peircej
pushed a commit
that referenced
this issue
Nov 6, 2020
peircej
pushed a commit
that referenced
this issue
Nov 12, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From PsychoPy's documentation:
The first item is incorrect: 0,2,5 gives the 1st, 3rd, and 6th entries.
The second item is just plain wrong as far as I understand. numpy's
random
function generates random numbers in the interval [0, 1), thusrandom(4)*10
(which by the way should be$random(4)*10
) generates 4 floating-point numbers in that interval. Multiplying by 10 thus generates 4 floating-point numbers in the [0, 10) interval. So these numbers are floats, not integers. But as far as I understand PsychoPy converts them to integers like this:Thus the numbers are rounded before being converted to integers. This means that numbers from 0 to 0.5 are converted to 0, numbers from 0.5 to 1.5 are converted to 1 and so on. Thus, there's a lower probability that 0 or 10 will be selected.
The probability for every number should be 1/11, but it's not.
In my opinion,
int(round(ii))
should be changed toint(np.floor(ii))
and the documentation to "random(4)*10 gives 4 indices from 0 to 9 (so selects 4 out of 10 conditions)." This will make sure every number has the same probability of being selected.The text was updated successfully, but these errors were encountered: