# Memory Probe - Random array followed by test

36 views

### Sam Morrison

May 30, 2021, 5:35:53 PMMay 30
to E-Prime
Hi all,

I am struggling to put an experiment together in E-Prime 3.0, and would really appreciate some help. I have searched the forum already, but have no found anything that really answers my question.

The basic set up is an attention task with a memory probe element. In each trial, participants are to be shown an array of 6 digits (randomized), followed by an attention task, and then a probe in which participants are shown a single digit and need to recall whether this digit was present in the array at the beginning of the trial - 50% of the time it is, and 50% of the time it is not.

I have the first part of the code, in that I can get the random array of 6 digits. What is less clear is how to code the probe so that it is counterbalanced. This would be fairly simple to write in python but I am struggling with EBasic.

Thanks,
Sam

### David McFarlane

Jun 1, 2021, 5:28:39 PMJun 1
Sam,

Let's start with your randomized array of 6 digits. So this is
essentially a 6-digit number from 000,000 to 999,999, right? How do you
generate these?

-- David McFarlane

### smo...@aucklanduni.ac.nz

Jun 1, 2021, 5:51:01 PMJun 1
Hi David,

Thanks so much for your reply. Here is my code for the random array. It's not pretty, but it works. This will generate a string of 6 nonrepeating digits. So now I need another bit of code to check which digits were selected, and either choose randomly from those digits or choose a digit that was not selected (counterbalanced). Participants will make a yes/no response to whether the probe digit appeared in the array or not.

Thanks,
Sam
----------------------
Dim Num1 As Integer
Dim Num2 As Integer
Dim Num3 As Integer
Dim Num4 As Integer
Dim Num5 As Integer
Dim Num6 As Integer

Num1 = Random(1,9)
Num2 = Random(1,9)
Num3 = Random(1,9)
Num4 = Random(1,9)
Num5 = Random(1,9)
Num6 = Random(1,9)

While (Num2 = Num1) = True
Num2 = Random(1,9)
Wend

While (Num3 = Num1) = True Or (Num3 = Num2) = True
Num3 = Random(1,9)
Wend

While (Num4 = Num1) = True Or (Num4 = Num2) = True Or (Num4 = Num3) = True
Num4 = Random(1,9)
Wend

While (Num5 = Num1) = True Or (Num5 = Num2) = True Or (Num5 = Num3) = True Or (Num5 = Num4) = True
Num5 = Random(1,9)
Wend

While (Num6 = Num1) = True Or (Num6 = Num2) = True Or (Num6 = Num3) = True Or (Num6 = Num4) = True Or (Num6 = Num5) = True
Num6 = Random(1,9)
Wend

c.SetAttrib "Num1", Num1
c.SetAttrib "Num2", Num2
c.SetAttrib "Num3", Num3
c.SetAttrib "Num4", Num4
c.SetAttrib "Num5", Num5
c.SetAttrib "Num6", Num6

-------------------
--
You received this message because you are subscribed to a topic in the Google Groups "E-Prime" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/e-prime/6mWyQvNjYUc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to e-prime+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/1b3488b8-16a6-cd1d-0f33-35b83d165d07%40msu.edu.

### David McFarlane

Jun 3, 2021, 4:47:14 PMJun 3
Sam,

So judging from your code, you want a set of six digits from 1 to 9 with
no repeated digits, and you want those digits arranged in some random
order. Just for fun, note that this results in 9*8*7*6*5*4 = 60,480
possible outcomes. There are better ways to program that either with or
without code. I would rather do this without code, using the List
facilities built into E-Prime, so let's explore that.

We will do this using nested Lists and colon notation -- if you are not
familiar with these, then look up these topics and work through the
tutorials in the Users Guide that comes with E-Prime.

Make a List -- let's call it "SixDigitList". Add six columns, and let's
call these "DigitA", "DigitB", etc. (or if you prefer, "Digit1", etc.).
Add a nested List, let's call it "DigitList".

Open the nested DigitList. Add a column called "Digit". Add 8 rows to
make 9 rows total. Put the numbers 1-9 into the rows. Leave Nested &
Procedure blank. Open the Properties pages for DigiList. Go to the
Selection tab and set Order to "Random"; go to the Reset/Exit tab and
enable "Reset at beginning of each Run".

Now go back to SixDigitList. Enter the following in the columns for
DigitA, DigitB, etc. (without the quote marks): "[Digit:0]",
"[Digit:1]", etc. (We could have done this step earlier, but for
didactic reasons we do it here.)

Now each time E-Prime runs that row of SixDigitList it will first
reshuffle DigitList and then put the first six shuffled values from
DigitList into the six attributes of SixDigitList. Easy peasy.

Go ahead and restructure your experiment like this, and once you get
that working we can move on to the next stage.

A few more notes on the side ...

If I wanted to do this with code instead of Lists, I would simply set up
an array with the 9 digits, do a Fisher-Yates shuffle of that array
(which is built in to E-Basic), and draw from the first six elements of
that shuffled array.

Note that all of these methods, including your code, allow the
possibility for the same digits in the same order to appear over
multiple trials. Preventing that possibility would add some
complication. (The simple way to do that would be to make a List of all
60,480 possibilities and then shuffle & draw samples from that List, but
that is not feasible :) .)

Finally, taking a broader view than just E-Prime for a moment -- In
order to solve randomization problems I first imagine how I would do it
with decks of physical playing cards, and then I simply implement that
in whatever programming platform I need to use. That is all that I have
done here.

-- David McFarlane

### Sam Morrison

Jun 4, 2021, 10:43:48 PMJun 4
to E-Prime
Hi David,

Thank you so much for your reply - this all makes complete sense. I don't think I had really considered the utility of the nested list function in E-Prime before, as my first instinct would be to just use code. I have restructured the experiment as you described, and await further instructions :)

The analogy with imaging a deck of cards is so useful. I will absolutely keep remember this for next time!

Thanks,
Sam

### David McFarlane

Jun 7, 2021, 8:36:15 PMJun 7
Sam,

OK, the next step gets tricky and takes some advanced use of nested
Lists, colon syntax, and nested attribute references, and it all comes
out quite nicely at the end.

Let's now call our main List "MemoryProbeList" (instead of
"SixDigitList"). We will end up with two or more rows in this List, but
let's start by structuring the first row.

Add a second nested List to the first (and so far only) row in
MemoryProbeList, and let's call that nested List "DigitPresentList".
Set up DigitPresentList with six rows. Add a column (i.e., attribute)
called "ProbePick", and fill it with the numbers 0-5 row by row -- we
will use this with colon syntax to pick one of the memorized digits,
remember that colon syntax starts from 0 instead of 1. Leave Nested &
Procedure empty, and set Selection to "Random with Replacement".

Go back to MemoryProbeList. Add an attribute (i.e., column) and let's
call it "ProbeDigit". Fill in the cell as follows (without the quote
marks): "[Digit:[ProbePick]]". This will use ProbePick to pick a
randomized offset from 0 to 5 into Digit, and then pick that randomized
Digit from DigitList. Neat huh? While we are at it, let's also add a
column named "ProbeType", and fill that in with "Present" -- this is
just information for us, it has no bearing on the actual operation of
the program (Michiel Spape calls these "latent" attributes, as opposed
to the "manifest" attributes that actually have an effect on the running
program).

You might as well pause at this point and see how this works so far.

You see where this is going by now. Next add a second row to
MemoryProbeList. Fill it in mostly just like the first row, except add
"DigitAbsentList" for the extra nested List (instead of
DigitPresentList), and set ProbeType to Absent. Then you have to set up
DigitAbsentList. For this one you want just three rows, with entries 6,
7, and 8, and again set Selection to "Random with Replacement". Now
this will randomly pick one of the three digits that was not memorized.

Finally, back at MemoryProbeList, give the same Weight to both the
"Present" & "Absent" rows, and set Selection to "Random". Note that you
can play some interesting randomization games here -- e.g., for 20 total
trials you could specify 10 trials of each kind and then randomize those
all at once, or specify 5 trials of each, randomizing 10 trials at a
time and then running two blocks of 10 trials, etc.

That should do it all, very compact and using no code at all! I will
send you separately a demo program to illustrate all this. This made
for an interesting little exercise to stretch my mind.

-- David McFarlane

### David McFarlane

Jun 8, 2021, 9:41:28 AMJun 8
Sam,

I just realized that adding a nested DigitAbsentList for the
digit-not-memorized trials is overkill. Instead, for the "Absent" row
of MemoryProbeList, you need only fill in ProbeDigit with "[Digit:6]"
(or [Digit:7] or [Digit:8] if you prefer), and then remove the
DigitAbsentList.

You need to go to extra trouble for the "Present" trials because you
want to randomly pick a digit from among another set of randomly
shuffled digits, whereas for the Absent trials you need merely pick
another digit from the shuffled digits.

-- David McFarlane

### Sam Morrison

Jun 8, 2021, 6:32:06 PMJun 8
to E-Prime
Hi David,

This is absolutely brilliant. It works exactly as I need it to.

Thank you so much for taking the time to help me solve this problem - and I really appreciate you taking the time to break it down and explain it so well too. I feel my E-Prime knowledge has definitely levelled up as a result!

This group is such fantastic resource - I can't thank you enough :)

All the best,
Sam