Creating list or vector with numerical values & getting n-th element out of this list


Author
Message
Olga Kunina
Olga Kunina
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 4, Visits: 1

Hi everyone,


I am trying
to expand the source code for the IOWA-Gambling task available at the Inquisit
website. In this version the loss-values are selected randomly as follows:


 <expressions>


/ getlossdeck1
= noreplace(0, 0, 0, 0, 0, 150, 200, 250, 300, 350) 


</expressions>


By contrast,
I want to define a fixed sequence of loss values for loss values for each trail.
I want to choose the current value depending on how many cards were already
taken from the deck. Speaking more technically - I want to get the nth element
out of an array, vector or list with numerical values.


Therefore I
am trying to define something like a list or a vector with loss values (integer
values) for each trail.


 / loss_deck1
= (0, 0, 0, 0, 0, 150, 200, 250, 300, 350) 


 Since that
did not work I have defined a counter


 <counter
deck1_loss>


/ items = (0,
0, 0, 0, 0, 150, 200, 250, 300, 350)


/ select = sequence(1-10)


</counter>


 Additionally,
I have introduced a variable "values.cards_deck1" that counts how
often deck1 was chosen. This counter is updated in each trial.


In the last
step I try to define the loss value for the current trial as:


/ getlossdeck1
= getitem(counter.deck1_loss.items, values.cards_deck1)


But each
time I get the error message "Expression is not valid. Item not found".


Does
someone have an idea whether it is possible to create a list or vector with
numerical values & get back a specific element out of this list?


Thanks a
lot for your help in advance.


Best regards, 


Olga Kunina


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: 95K

Can you tell me how one would have to define "counter.deck", "text.presenteditems", or "item.useritems" so that this function is executed regularely?


Hmm, I don't think there's much more too it. Let's do this by way of an example. Suppose you have defined a counter element:


<counter fruit>
/ items = ("apple", "banana", "cherry", "damson", "elderberry")
[...]
</counter>


Now, suppose you want to retrieve the third item from the counter, i.e. "cherry", with the getitem function. You can use that function either by way of the <expressions> element


<expressions>
/ getcherry = getitem(counter.fruit, 3)
[...]
</expressions>


or by way of Inquisit's event attributes ('/ onexptbegin', '/ onexptend', '/ onblockbegin', '/ onblockend', '/ ontrialbegin', '/ ontrialend') available at the <expt>, <block> and <trial> level


<trial getcherry>
/ ontrialbegin = [text.favoritefruit.item.1 = getitem(counter.fruit, 3)]
/ stimulusframes = [favoritefruit]
[...]
</trial>

<text favoritefruit>
[...]
</text>


and do all sorts of things with it, e.g. write it to a <text> element or to a <values> entry. Note that the item index number, i.e. the second argument of the getitem function  ( 3 for "cherry") may also be a variable. So you might as well define another <values> entry (or use anything that returns a valid numerical value) and use it as the functions argument:


<values>
/ cherryindex = 3
[...]
</values>


<expressions>

/ getcherry = getitem(counter.fruit, values.cherryindex)

[...]

</expressions>


Best wishes from a fellow Inquisit user,


~Dave


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search