Using Random Values

Generating Random Values

In some cases you may want to generate random values within your input file. For example, you might want DirectRT to generate random display times, a random location, a random filename and so on. Until now, randomization has required stimulus lists or trial order arrangement to achieve these kind of results. DirectRT now gives you two fun new randomization methods.

Random Number Within a Range

To have DirectRT generate a random value within a numerical range, simply request it using the rand() keyword, and indicate the minimum and maximum values in parentheses, separated by a dash like this:

rand(min,max)

For example, if you want an image displayed for a random duration within the range of 500 to 2000 milliseconds, simply enter rand(500-2000) in your Time column. DirectRT will find this request and replace it with a random integer value between 500 and 2000.

Random Value from a List

To have DirectRT randomly pick one value from a list, simply request it using the rand() keyword, and indicate the choices in parentheses, separated by commas:

rand(choice 1,choice 2,choice 3,...,choice n)

For example, if you want an image displayed for a random interval of either 500, 1000, 1500, or 2000 milliseconds, simply enter rand(500,1000,1500,2000) in your Time column.

You could also choose a random stimulus this way:

rand(~cat,~dog,~frog)

Note that the rand() keyword can take up a whole cell like in the examples above or it can make up just part of a cell:

~Please count to rand(1-100) out loud

Or, to pick from a set of images:

C:\image\imagerand(1,2,12,17,33).bmp

How it Works

Both work by inserting a special keyword "rand()" into your input file. Before doing anything else, DirectRT will scan your input file for this keyword and generate random values wherever you've asked for it to do so. You can request this *anywhere* in your input file. It will generate the random value as requested and replace the request with the randomized value. DirectRT will then save the results as a new input file--it will share the same name as the original file but will have the subject ID appended to it. So if your file is called "myfile.csv" and your subject ID is 22, then the new input file will be called "myfile_22.csv" and this is the file that DirectRT will run.

In fact, this is a good way to check if you're getting the randomization values you want--after the session, you can open the revised input file and see the actual random values that DirectRT generated. The log data file will also be a good source of information on what random values were generated.