By AndrewPapale - 10/2/2023
Dear Inquisit Team,
What is the best way to find the index of a value in the max function?
i.e. index of max(4,0,1,3,2) would return 2, index of max(2,3,4,1,5) would return 4.
I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htm
Thanks, Andrew
|
By AndrewPapale - 10/2/2023
+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks
|
By AndrewPapale - 10/2/2023
+x+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks This solution seems to work for values <=5 but is not general to any integer N without N if else statements.
<list best> / items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5) / poolsize = 6 / selectionrate = always </list>
|
By Dave - 10/2/2023
+x+x+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks This solution seems to work for values <=5 but is not general to any integer N without N if else statements. <list best> / items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5) / poolsize = 6 / selectionrate = always </list> I'm not at all sure what you want to do and for what purpose. Give a concrete example, please.
|
By AndrewPapale - 10/2/2023
+x+x+x+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks This solution seems to work for values <=5 but is not general to any integer N without N if else statements. <list best> / items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5) / poolsize = 6 / selectionrate = always </list> I'm not at all sure what you want to do and for what purpose. Give a concrete example, please. It's very simple. I want to find the index for which the minimum value occurs. i.e. if I have a set of numbers in a specific sequence, I want to be able to find the index of the minimum of that sequence. In R programming language this is the which.min() function. Here is how you'd do it in Python: https://stackoverflow.com/questions/2474015/getting-the-index-of-the-returned-max-or-min-item-using-max-min-on-a-list
The purpose of doing this is to dynamically change block lengths depending on contingency to keep 3 conditions as balanced as possible while accounting for variable subject behavior.
|
By Dave - 10/2/2023
+x+x+x+x+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks This solution seems to work for values <=5 but is not general to any integer N without N if else statements. <list best> / items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5) / poolsize = 6 / selectionrate = always </list> I'm not at all sure what you want to do and for what purpose. Give a concrete example, please. It's very simple. I want to find the index for which the minimum value occurs. i.e. if I have a set of numbers in a specific sequence, I want to be able to find the index of the minimum of that sequence. In R programming language this is the which.min() function. Here is how you'd do it in Python: https://stackoverflow.com/questions/2474015/getting-the-index-of-the-returned-max-or-min-item-using-max-min-on-a-listThe purpose of doing this is to dynamically change block lengths depending on contingency to keep 3 conditions as balanced as possible while accounting for variable subject behavior. A list has maximum and minimum properties.
https://www.millisecond.com/support/docs/current/html/language/properties/maximum.htm https://www.millisecond.com/support/docs/current/html/language/properties/minimum.htm https://www.millisecond.com/support/docs/current/html/language/elements/list.htm
So, first get the maximum (or minimum, whatever you're interested in) value, then use indexof() to find that value's index.
<list mylist> / items = (12, 9, 15, 7, 13, 7) </list>
<values> / min = null / max = null / iMin = -1 / iMax = -1 </values>
<trial mytrial> / ontrialbegin = [ values.min = list.mylist.minimum; values.iMin = list.mylist.indexof(values.min); values.max = list.mylist.maximum; values.iMax = list.mylist.indexof(values.max); ] / stimulusframes = [1=mytext] / validresponse = (57) </trial>
<text mytext> / items = ("List: <%list.mylist.item(1)%>, <%list.mylist.item(2)%>, <%list.mylist.item(3)%>, <%list.mylist.item(4)%>, <%list.mylist.item(5)%>, <%list.mylist.item(6)%> Min: <%values.min%> at index <%values.iMin%> Max: <%values.max%> at index <%values.iMax%>") </text>
If there are multiple values equal to max or min, indexof() returns the index of the first value matching max or min.
|
By AndrewPapale - 10/2/2023
+x+x+x+x+x+xDear Inquisit Team, What is the best way to find the index of a value in the max function? i.e. index of max(4,0,1,3,2) would return 1, index of max(2,3,4,1,5) would return 5. I feel like there might be a way to do this with lists: https://www.millisecond.com/support/docs/current/html/language/functions/indexof.htmThanks, Andrew Not sure how to edit, but obviously the examples I gave would be for the min function. For the max, we would return 1 and 5, respectively, thanks This solution seems to work for values <=5 but is not general to any integer N without N if else statements. <list best> / items = (values.rem0, values.rem1, values.rem2, values.rem3, values.rem4, values.rem5) / poolsize = 6 / selectionrate = always </list> I'm not at all sure what you want to do and for what purpose. Give a concrete example, please. It's very simple. I want to find the index for which the minimum value occurs. i.e. if I have a set of numbers in a specific sequence, I want to be able to find the index of the minimum of that sequence. In R programming language this is the which.min() function. Here is how you'd do it in Python: https://stackoverflow.com/questions/2474015/getting-the-index-of-the-returned-max-or-min-item-using-max-min-on-a-listThe purpose of doing this is to dynamically change block lengths depending on contingency to keep 3 conditions as balanced as possible while accounting for variable subject behavior. A list has maximum and minimum properties. https://www.millisecond.com/support/docs/current/html/language/properties/maximum.htmhttps://www.millisecond.com/support/docs/current/html/language/elements/list.htmSo, first get the maximum (or minimum, whatever you're interested in) value, then use indexof() to find that value's index. <list mylist> / items = (12, 9, 15, 7, 13, 7) </list>
<values> / min = null / max = null / iMin = -1 / iMax = -1 </values>
<trial mytrial> / ontrialbegin = [ values.min = list.mylist.minimum; values.iMin = list.mylist.indexof(values.min); values.max = list.mylist.maximum; values.iMax = list.mylist.indexof(values.max); ] / stimulusframes = [1=mytext] / validresponse = (57) </trial>
<text mytext> / items = ("List: <%list.mylist.item(1)%>, <%list.mylist.item(2)%>, <%list.mylist.item(3)%>, <%list.mylist.item(4)%>, <%list.mylist.item(5)%>, <%list.mylist.item(6)%> Min: <%values.min%> at index <%values.iMin%> Max: <%values.max%> at index <%values.iMax%>") </text>
If there are multiple values equal to max or min, indexof() returns the index of the first value matching max or min. Thank you I was close. DIdn't know about the min max property of lists. Appreciate your help.
|
|