Random number generator won't accurately save to data


Author
Message
crannie
crannie
Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)
Group: Forum Members
Posts: 2, Visits: 1

Hi all,


I have a problem with my script. I have set a random number to be generated in order to be used as a cognitive load manipulation. So at the start of the experiment, participants observe a random 3 digit number, complete a number of set tasks and at the end of the experiment they are asked to recall the 3 digit number that was shown at the beginning.


The problem is however, that when the data is saved, the 3 digit number shown in the data log is different to the 3 digit number that is actually displayed to participants (e.g. participants see "324" but the data log records "457").


What is causing this problem and how do I fix it?


Thanks!



The relevant script sections are shown below:









<data>


/file =
"StroopWithControlKeyboard_raw.iqdat"


/separatefiles = true


/ columns = [date time subject blockcode
trialcode stimulusitem stimulusitem stimulusitem trialnum latency response
correct expressions.unrelatedlatency expressions.targetlatency expressions.unrelatedcorrect
expressions.targetcorrect]


</data>






<text numberload>

/ items = ("<%round(rand(100, 999))%>")

/ position = (50%, 50%)

/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 0)

/ txcolor = darkblue

</text>




<text numberreminder>

/ items = ("Please remember this number until we ask you to type it in")

/ position = (50%, 30%)

/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 0)

/ txcolor = darkgray

/ erase = false

</text>




<trial numprompt>

/ pretrialpause = 1000

/ stimulustimes = [1=numberreminder; 2000=numberload]

/ recorddata = true

/ timeout = 5000

</trial>




<block block5>

/ trials = [1=numprompt]

</block>




<expt>

/ blocks = [1=block5]

</expt>








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: 13K, Visits: 108K

What is causing this problem and how do I fix it?


The problem is that you are generating the random number inline. Each time the respective <text> element is queried, a new random number will be generated. The <text> element is queried *twice*, once when it's displayed on screen and second time when it's written to the data file. Thus the discrepancy. The solution is to store your random number in a <values> entry instead of using an inline expression.


Cf. http://www.millisecond.com/forums/Topic6753.aspx#6753


crannie
crannie
Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)Associate Member (74 reputation)
Group: Forum Members
Posts: 2, Visits: 1

thanks for your help!!


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search