﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Millisecond Forums » Millisecond Forums » Inquisit 5  » Using rand(x,y) in expressions</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Tue, 15 Sep 2026 22:54:19 GMT</lastBuildDate><ttl>20</ttl><item><title>Using rand(x,y) in expressions</title><link>https://forums.millisecond.com/Topic26101.aspx</link><description>Hi,&lt;br/&gt;&lt;br/&gt;just a quick question: if I set up an expression that includes a rand(x,y) function, will the random number be picked once or will it be repicked every time the expression is called? So for example:&lt;br/&gt;&lt;br/&gt;&amp;lt;expressions&amp;gt;&lt;br/&gt;/ MyExpression = 100 + rand(-50,50)&lt;br/&gt;&amp;lt;/expressions&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial Tester&amp;gt;&lt;br/&gt;/ stimulustimes = [0 = TestText]&lt;br/&gt;/ validresponse = (" ")&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text TestText&amp;gt;&lt;br/&gt;/ items = ("Showing number &amp;lt;%expressions.MyExpression%&amp;gt;")&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;If trial.Tester is repeated, will there be different values for MyExpression shown? If not, are there any circumstances that might cause the expression to draw a new random number? I'm asking because the closest analogues, new elements from lists, appear to be accessed only when called via a reference to list.MyList.nextitem in an ontrialbegin/ontrialend/branch, not when referenced in a text object using &amp;lt;%list.MyList.nextitem%&amp;gt; - or at least that was my understanding.&lt;br/&gt;&lt;br/&gt;Thanks for any help!&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description><pubDate>Thu, 22 Nov 2018 08:11:00 GMT</pubDate><dc:creator>AKrishna</dc:creator></item><item><title>RE: Using rand(x,y) in expressions</title><link>https://forums.millisecond.com/Topic26105.aspx</link><description>&lt;div data-id="26102" class="if-quote-wrapper" unselectable="on" data-guid="1542902763924"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="26102" title="Move Cursor Below" contenteditable="false"&gt;&lt;span unselectable="on"&gt;+&lt;/span&gt;&lt;/a&gt;&lt;a class="quote-delete" unselectable="on" style="display: none;" href="#" data-id="26102" title="Delete Quote" contenteditable="false"&gt;&lt;span unselectable="on"&gt;x&lt;/span&gt;&lt;/a&gt;&lt;span unselectable="on" class="quote-markup"&gt;[quote]&lt;/span&gt;&lt;div unselectable="on" class="if-quote-header" contenteditable="false"&gt;&lt;div unselectable="on" class="if-quote-toggle-wrapper"&gt;&lt;a class="if-quote-toggle quote-link" href="#" data-id="26102" title=" "&gt;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;AKrishna - Thursday, November 22, 2018&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-26102"&gt;&lt;div class="if-quote-message-margin"&gt;&lt;div data-id="26101" class="if-quote-wrapper" unselectable="on" data-guid="1542902763924"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="26101" title="Move Cursor Below" contenteditable="false"&gt;&lt;span unselectable="on"&gt;+&lt;/span&gt;&lt;/a&gt;&lt;a class="quote-delete" unselectable="on" style="display: none;" href="#" data-id="26101" title="Delete Quote" contenteditable="false"&gt;&lt;span unselectable="on"&gt;x&lt;/span&gt;&lt;/a&gt;&lt;span unselectable="on" class="quote-markup"&gt;[quote]&lt;/span&gt;&lt;div unselectable="on" class="if-quote-header" contenteditable="false"&gt;&lt;div unselectable="on" class="if-quote-toggle-wrapper"&gt;&lt;a class="if-quote-toggle quote-link" href="#" data-id="26101" title=" "&gt;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;AKrishna - Thursday, November 22, 2018&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-26101"&gt;&lt;div class="if-quote-message-margin"&gt;Hi,&lt;br/&gt;&lt;br/&gt;just a quick question: if I set up an expression that includes a rand(x,y) function, will the random number be picked once or will it be repicked every time the expression is called? So for example:&lt;br/&gt;&lt;br/&gt;&amp;lt;expressions&amp;gt;&lt;br/&gt;/ MyExpression = 100 + rand(-50,50)&lt;br/&gt;&amp;lt;/expressions&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial Tester&amp;gt;&lt;br/&gt;/ stimulustimes = [0 = TestText]&lt;br/&gt;/ validresponse = (" ")&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text TestText&amp;gt;&lt;br/&gt;/ items = ("Showing number &amp;lt;%expressions.MyExpression%&amp;gt;")&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;If trial.Tester is repeated, will there be different values for MyExpression shown? If not, are there any circumstances that might cause the expression to draw a new random number? I'm asking because the closest analogues, new elements from lists, appear to be accessed only when called via a reference to list.MyList.nextitem in an ontrialbegin/ontrialend/branch, not when referenced in a text object using &amp;lt;%list.MyList.nextitem%&amp;gt; - or at least that was my understanding.&lt;br/&gt;&lt;br/&gt;Thanks for any help!&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;a class="if-quote-goto quote-link" href="#" data-id="26101"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/div&gt;&lt;br/&gt;...and then I realized I could just run my own example code several times.&lt;br/&gt;&lt;br/&gt;So expressions do grab a new random number each time they are referenced. And it also turns out I was wrong: lists do grab new list elements even if the only reference to a new element in the trial is in a &amp;lt;text&amp;gt; stimulus using &amp;lt;%list.MyList.nextvalue%&amp;gt;.&lt;br/&gt;&lt;br/&gt;So if anyone was wondering...&lt;br/&gt;&lt;a class="if-quote-goto quote-link" href="#" data-id="26102"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/div&gt;&lt;br/&gt;Just chiming in to confirm: Yes, that's correct, an expression will (and is supposed to) return a new value every time it is called. For &amp;lt;list&amp;gt; elements, things depend on their /selectionrate setting. The default behavior is /selectionrate = trial, i.e. the list will return one item from its pool when it is used in some way in a &amp;lt;trial&amp;gt;. Subsequent references to the list during that instance of the &amp;lt;trial&amp;gt; would return the same value. If the list is set to /selectionrate = always, however, it would perform a new selection every time it is referenced during a given instance of a &amp;lt;trial&amp;gt;.&lt;br/&gt;</description><pubDate>Thu, 22 Nov 2018 08:11:00 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: Using rand(x,y) in expressions</title><link>https://forums.millisecond.com/Topic26102.aspx</link><description>&lt;div data-id="26101" class="if-quote-wrapper" unselectable="on" data-guid="1542881496758"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="26101" title="Move Cursor Below" contenteditable="false"&gt;&lt;span unselectable="on"&gt;+&lt;/span&gt;&lt;/a&gt;&lt;a class="quote-delete" unselectable="on" style="display: none;" href="#" data-id="26101" title="Delete Quote" contenteditable="false"&gt;&lt;span unselectable="on"&gt;x&lt;/span&gt;&lt;/a&gt;&lt;span unselectable="on" class="quote-markup"&gt;[quote]&lt;/span&gt;&lt;div unselectable="on" class="if-quote-header" contenteditable="false"&gt;&lt;div unselectable="on" class="if-quote-toggle-wrapper"&gt;&lt;a class="if-quote-toggle quote-link" href="#" data-id="26101" title=" "&gt;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;AKrishna - Thursday, November 22, 2018&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-26101"&gt;&lt;div class="if-quote-message-margin"&gt;Hi,&lt;br/&gt;&lt;br/&gt;just a quick question: if I set up an expression that includes a rand(x,y) function, will the random number be picked once or will it be repicked every time the expression is called? So for example:&lt;br/&gt;&lt;br/&gt;&amp;lt;expressions&amp;gt;&lt;br/&gt;/ MyExpression = 100 + rand(-50,50)&lt;br/&gt;&amp;lt;/expressions&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial Tester&amp;gt;&lt;br/&gt;/ stimulustimes = [0 = TestText]&lt;br/&gt;/ validresponse = (" ")&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text TestText&amp;gt;&lt;br/&gt;/ items = ("Showing number &amp;lt;%expressions.MyExpression%&amp;gt;")&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;If trial.Tester is repeated, will there be different values for MyExpression shown? If not, are there any circumstances that might cause the expression to draw a new random number? I'm asking because the closest analogues, new elements from lists, appear to be accessed only when called via a reference to list.MyList.nextitem in an ontrialbegin/ontrialend/branch, not when referenced in a text object using &amp;lt;%list.MyList.nextitem%&amp;gt; - or at least that was my understanding.&lt;br/&gt;&lt;br/&gt;Thanks for any help!&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;a class="if-quote-goto quote-link" href="#" data-id="26101"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/div&gt;&lt;br/&gt;...and then I realized I could just run my own example code several times.&lt;br/&gt;&lt;br/&gt;So expressions do grab a new random number each time they are referenced. And it also turns out I was wrong: lists do grab new list elements even if the only reference to a new element in the trial is in a &amp;lt;text&amp;gt; stimulus using &amp;lt;%list.MyList.nextvalue%&amp;gt;.&lt;br/&gt;&lt;br/&gt;So if anyone was wondering...&lt;br/&gt;</description><pubDate>Thu, 22 Nov 2018 02:14:21 GMT</pubDate><dc:creator>AKrishna</dc:creator></item></channel></rss>