Ordering List Based on Standard Deviation


Author
Message
ivy.c
ivy.c
New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)
Group: Forum Members
Posts: 11, Visits: 143
Hello,

I’m currently trying to sort through a list of RT’s and only create a list of values that are 3 standard deviations from the mean. I currently have the following variables:
/meanCorrRT_SD = list.corrRT_baseline_short.mean
/SD = list.corrRT_baseline_short.standarddeviation
/maxRT = expressions.meanCorrRT_SD + 3*expressions.SD

What I would like to do at the end of the block is to order the RT’s from the ‘corrRT_baseline_short’ list in ascending order but exclude values that are larger than the maxRT value. From that list, I would like to pick the 3rd number on that list. I have at the end of my block the following:
/ onblockend = [list.corrRT_baseline_short.sort(false,false);    
values.index = 3;
values.cutoff_RT = list.corrRT_baseline_short.item(values.index);
]
</block>

I believe I have figured out how to calculate the SD, but I am unsure how to exclude and order the list (and therefore, change the /onblockend script accordingly). Any help would be appreciated. Thank you!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 83K
ivy.c - 6/20/2022
Hello,

I’m currently trying to sort through a list of RT’s and only create a list of values that are 3 standard deviations from the mean. I currently have the following variables:
/meanCorrRT_SD = list.corrRT_baseline_short.mean
/SD = list.corrRT_baseline_short.standarddeviation
/maxRT = expressions.meanCorrRT_SD + 3*expressions.SD

What I would like to do at the end of the block is to order the RT’s from the ‘corrRT_baseline_short’ list in ascending order but exclude values that are larger than the maxRT value. From that list, I would like to pick the 3rd number on that list. I have at the end of my block the following:
/ onblockend = [list.corrRT_baseline_short.sort(false,false);    
values.index = 3;
values.cutoff_RT = list.corrRT_baseline_short.item(values.index);
]
</block>

I believe I have figured out how to calculate the SD, but I am unsure how to exclude and order the list (and therefore, change the /onblockend script accordingly). Any help would be appreciated. Thank you!

First you need to step through all items in the corrRT_baseline_short list in a while loop, look at each item's value (i.e. the individual RT) and append the given item to a new list if it is smaller than the cut-off value (max RT). Then sort the new list and pick its 3rd item.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 83K
Dave - 6/20/2022
ivy.c - 6/20/2022
Hello,

I’m currently trying to sort through a list of RT’s and only create a list of values that are 3 standard deviations from the mean. I currently have the following variables:
/meanCorrRT_SD = list.corrRT_baseline_short.mean
/SD = list.corrRT_baseline_short.standarddeviation
/maxRT = expressions.meanCorrRT_SD + 3*expressions.SD

What I would like to do at the end of the block is to order the RT’s from the ‘corrRT_baseline_short’ list in ascending order but exclude values that are larger than the maxRT value. From that list, I would like to pick the 3rd number on that list. I have at the end of my block the following:
/ onblockend = [list.corrRT_baseline_short.sort(false,false);    
values.index = 3;
values.cutoff_RT = list.corrRT_baseline_short.item(values.index);
]
</block>

I believe I have figured out how to calculate the SD, but I am unsure how to exclude and order the list (and therefore, change the /onblockend script accordingly). Any help would be appreciated. Thank you!

First you need to step through all items in the corrRT_baseline_short list in a while loop, look at each item's value (i.e. the individual RT) and append the given item to a new list if it is smaller than the cut-off value (max RT). Then sort the new list and pick its 3rd item.

In a nutshell:

<list exampleRTs>
/ items = (
4580, 3928, 341, 363, 380, 280, 245, 356, 327, 254,
276, 293, 346 ,264, 246, 254, 253, 359, 272, 367,
250, 387, 404, 298, 327, 321, 401, 326, 410, 318,
295, 327, 247, 254, 369, 323, 249, 399, 340, 315,
304, 416, 351, 400, 410, 367, 281, 409, 311, 390,
347, 295, 368, 414, 262, 289, 267, 369, 297, 306,
420, 306, 255, 280, 390, 348, 398, 387, 398, 388,
251, 374, 269, 392, 355, 298, 249, 311, 377, 313,
260, 272, 372, 309, 409, 287, 262, 384, 273, 282,
330, 276, 415, 282, 418, 274, 307, 260, 399, 283)
</list>

<expressions>
/ meanRT = list.exampleRTs.mean
/ sdRT = list.exampleRTs.standarddeviation
/ maxRT = expressions.meanRT + 3 * expressions.sdRT
</expressions>

<list newlist>
</list>

<block exampleblock>
/ preinstructions = (a)
/ postinstructions = (b)
/ onblockend = [
    var i = 0;
    var rt = 0;
    while (i < list.exampleRTs.itemcount) {
        i += 1;
         rt = list.exampleRTs.item(i);
         if (rt < expressions.maxRT) {
            list.newlist.appenditem(rt);
         };
    };
    list.newlist.sort(true, false);
    
]
</block>

<page a>
^m(rt) = <%expressions.meanRT%> sd(rt) = <%expressions.sdRT%> -> m+3sd = <%expressions.maxRT%>

^^original list contains <%list.exampleRTs.itemcount%> RTs.
^minimum rt in original list: <%list.exampleRTs.minimum%>
^maximum rt in original list: <%list.exampleRTs.maximum%>

^^first three values in original list: <%list.exampleRTs.item(1)%>, <%list.exampleRTs.item(2)%>, <%list.exampleRTs.item(3)%>
^last three values in original list: <%list.exampleRTs.item(list.exampleRTs.itemcount-2)%>, <%list.exampleRTs.item(list.exampleRTs.itemcount-1)%>, <%list.exampleRTs.item(list.exampleRTs.itemcount)%>
</page>

<page b>
^m(rt) = <%expressions.meanRT%> sd(rt) = <%expressions.sdRT%> -> m+3sd = <%expressions.maxRT%>

^^sorted list contains <%list.newlist.itemcount%> RTs.
^minimum rt in sorted list: <%list.newlist.minimum%>
^maximum rt in sorted list: <%list.newlist.maximum%>

^^first three values in sorted list: <%list.newlist.item(1)%>, <%list.newlist.item(2)%>, <%list.newlist.item(3)%>
^last three values in sorted list: <%list.newlist.item(list.newlist.itemcount-2)%>, <%list.newlist.item(list.newlist.itemcount-1)%>, <%list.newlist.item(list.newlist.itemcount)%>
</page>

Edited Last Month by Dave
ivy.c
ivy.c
New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)
Group: Forum Members
Posts: 11, Visits: 143
Dave - 6/20/2022
Dave - 6/20/2022
ivy.c - 6/20/2022
Hello,

I’m currently trying to sort through a list of RT’s and only create a list of values that are 3 standard deviations from the mean. I currently have the following variables:
/meanCorrRT_SD = list.corrRT_baseline_short.mean
/SD = list.corrRT_baseline_short.standarddeviation
/maxRT = expressions.meanCorrRT_SD + 3*expressions.SD

What I would like to do at the end of the block is to order the RT’s from the ‘corrRT_baseline_short’ list in ascending order but exclude values that are larger than the maxRT value. From that list, I would like to pick the 3rd number on that list. I have at the end of my block the following:
/ onblockend = [list.corrRT_baseline_short.sort(false,false);    
values.index = 3;
values.cutoff_RT = list.corrRT_baseline_short.item(values.index);
]
</block>

I believe I have figured out how to calculate the SD, but I am unsure how to exclude and order the list (and therefore, change the /onblockend script accordingly). Any help would be appreciated. Thank you!

First you need to step through all items in the corrRT_baseline_short list in a while loop, look at each item's value (i.e. the individual RT) and append the given item to a new list if it is smaller than the cut-off value (max RT). Then sort the new list and pick its 3rd item.

In a nutshell:

<list exampleRTs>
/ items = (
4580, 3928, 341, 363, 380, 280, 245, 356, 327, 254,
276, 293, 346 ,264, 246, 254, 253, 359, 272, 367,
250, 387, 404, 298, 327, 321, 401, 326, 410, 318,
295, 327, 247, 254, 369, 323, 249, 399, 340, 315,
304, 416, 351, 400, 410, 367, 281, 409, 311, 390,
347, 295, 368, 414, 262, 289, 267, 369, 297, 306,
420, 306, 255, 280, 390, 348, 398, 387, 398, 388,
251, 374, 269, 392, 355, 298, 249, 311, 377, 313,
260, 272, 372, 309, 409, 287, 262, 384, 273, 282,
330, 276, 415, 282, 418, 274, 307, 260, 399, 283)
</list>

<expressions>
/ meanRT = list.exampleRTs.mean
/ sdRT = list.exampleRTs.standarddeviation
/ maxRT = expressions.meanRT + 3 * expressions.sdRT
</expressions>

<list newlist>
</list>

<block exampleblock>
/ preinstructions = (a)
/ postinstructions = (b)
/ onblockend = [
    var i = 0;
    var rt = 0;
    while (i < list.exampleRTs.itemcount) {
        i += 1;
         rt = list.exampleRTs.item(i);
         if (rt < expressions.maxRT) {
            list.newlist.appenditem(rt);
         };
    };
    list.newlist.sort(true, false);
    
]
</block>

<page a>
^m(rt) = <%expressions.meanRT%> sd(rt) = <%expressions.sdRT%> -> m+3sd = <%expressions.maxRT%>

^^original list contains <%list.exampleRTs.itemcount%> RTs.
^minimum rt in original list: <%list.exampleRTs.minimum%>
^maximum rt in original list: <%list.exampleRTs.maximum%>

^^first three values in original list: <%list.exampleRTs.item(1)%>, <%list.exampleRTs.item(2)%>, <%list.exampleRTs.item(3)%>
^last three values in original list: <%list.exampleRTs.item(list.exampleRTs.itemcount-2)%>, <%list.exampleRTs.item(list.exampleRTs.itemcount-1)%>, <%list.exampleRTs.item(list.exampleRTs.itemcount)%>
</page>

<page b>
^m(rt) = <%expressions.meanRT%> sd(rt) = <%expressions.sdRT%> -> m+3sd = <%expressions.maxRT%>

^^sorted list contains <%list.newlist.itemcount%> RTs.
^minimum rt in sorted list: <%list.newlist.minimum%>
^maximum rt in sorted list: <%list.newlist.maximum%>

^^first three values in sorted list: <%list.newlist.item(1)%>, <%list.newlist.item(2)%>, <%list.newlist.item(3)%>
^last three values in sorted list: <%list.newlist.item(list.newlist.itemcount-2)%>, <%list.newlist.item(list.newlist.itemcount-1)%>, <%list.newlist.item(list.newlist.itemcount)%>
</page>

Hi Dave,

Thanks so much for providing an example!

To confirm, is the <list exampleRTs> equivalent to what I have been referring to as my <list corrRT_baseline_short>? I ask this because my corrRT_baseline_short records the RT from each trial during a block, so in my script the list <corrRT_baseline_short> remains blank (I’m not sure if the items need to be stored manually ahead of time?). Regardless, I’ve tried to update my script to the one below (I also added in the values.index = 3, to select the the 3rd item from the new new list):

<expressions>
/meanCorrRT_SD = list.corrRT_baseline_short.mean
/SD = list.corrRT_baseline_short.standarddeviation
/maxRT = expressions.meanCorrRT_SD + 3*expressions.SD

<list corrRT_baseline_short>
</list>

<trial exampletrial>
/ ontrialend = [
        list.corrRT_baseline_short.appenditem(trial.exampletrial.latency);

<block exampleblock>
/ onblockend = [
    var i = 0;
    var rt = 0;
    while (i < list.corrRT_baseline_short.itemcount) {
        i += 1;
         rt = list.corrRT_baseline_short.item(i);
         if (rt < expressions.maxRT) {
            list.newlist.appenditem(rt);
         };
    };
    list.newlist.sort(true, false);
    values.index = 3;
    values.cutoff_RT = list.newlist.item(values.index);
]
</block>

I’ve tried to adjust your example according to my current script, I’ve run into an error message where it says the ‘ i’ Expression contains an unknown element or property name. I’m not sure why this error message is appearing?

Thanks again for your assistance!


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 83K
> To confirm, is the <list exampleRTs> equivalent to what I have been referring to as my <list corrRT_baseline_short>?

Yes.

> I ask this because my corrRT_baseline_short records the RT from each trial during a block, so in my script the list <corrRT_baseline_short> remains blank.

Your list isn't empty by the time you perform the operations. It doesn't matter that it starts out empty.

> I’ve tried to adjust your example according to my current script, I’ve run into an error message where it says the ‘ i’ Expression contains an unknown element or property name. I’m not sure why this error message is appearing?

You've asked this question in the Inquisit 6 forum, so the syntax I gave you works under Inquisit 6. It won't work under Inquisit 5 or below. Inquisit 5 has no temporary vars, nor does it have while loops.

ivy.c
ivy.c
New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)New Member (45 reputation)
Group: Forum Members
Posts: 11, Visits: 143
Dave - 6/20/2022
> To confirm, is the <list exampleRTs> equivalent to what I have been referring to as my <list corrRT_baseline_short>?

Yes.

> I ask this because my corrRT_baseline_short records the RT from each trial during a block, so in my script the list <corrRT_baseline_short> remains blank.

Your list isn't empty by the time you perform the operations. It doesn't matter that it starts out empty.

> I’ve tried to adjust your example according to my current script, I’ve run into an error message where it says the ‘ i’ Expression contains an unknown element or property name. I’m not sure why this error message is appearing?

You've asked this question in the Inquisit 6 forum, so the syntax I gave you works under Inquisit 6. It won't work under Inquisit 5 or below. Inquisit 5 has no temporary vars, nor does it have while loops.

Thanks for confirming! I am running this script using Inquisit 6 so I'm unsure why I'm getting this error message?


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 83K
ivy.c - 6/20/2022
Dave - 6/20/2022
> To confirm, is the <list exampleRTs> equivalent to what I have been referring to as my <list corrRT_baseline_short>?

Yes.

> I ask this because my corrRT_baseline_short records the RT from each trial during a block, so in my script the list <corrRT_baseline_short> remains blank.

Your list isn't empty by the time you perform the operations. It doesn't matter that it starts out empty.

> I’ve tried to adjust your example according to my current script, I’ve run into an error message where it says the ‘ i’ Expression contains an unknown element or property name. I’m not sure why this error message is appearing?

You've asked this question in the Inquisit 6 forum, so the syntax I gave you works under Inquisit 6. It won't work under Inquisit 5 or below. Inquisit 5 has no temporary vars, nor does it have while loops.

Thanks for confirming! I am running this script using Inquisit 6 so I'm unsure why I'm getting this error message?


Give me the actual script, not some isolated and incomplete snippets, and then I might be able to tell you.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search