There seems to be a bug in the randomization of the catindex.
If you look closely at the output file it looks something like that :
9834076,0,0,B,0,0,3220
9834076,0,1,B,3,0,1024
9834076,0,2,B,0,0,2159
9834076,0,3,W,3,0,1023
9834076,0,4,W,0,0,784
9834076,0,5,B,4,0,832
9834076,0,6,W,0,0,784
9834076,0,7,B,5,0,744
9834076,0,8,B,0,0,1096
9834076,0,9,B,3,0,656
9834076,0,10,W,0,0,760
9834076,0,11,W,1,0,656
9834076,0,12,B,0,0,624
9834076,0,13,W,5,0,2176
9834076,0,14,W,0,0,1384
notice that the catindex pattern is : 0,3,0,3,0,5, 0, 3, 0, 1
this is cause by this code :
prevIndexA = -1; prevIndex1 = -1;
for (var j = 0; j<numrounds; j++)
{
var round = new IATround();
if (stype == "target")
{
round.category = (Math.random() < 0.5 ? input.catA.datalabel : input.catB.datalabel);
}
else if (stype == "association")
{
round.category = (Math.random() < 0.5 ? input.cat1.datalabel : input.cat2.datalabel);
}
else if (stype == "both")
{
if (j % 2 == 0) { round.category = (Math.random() < 0.5 ? input.catA.datalabel : input.catB.datalabel); }
else { round.category = (Math.random() < 0.5 ? input.cat1.datalabel : input.cat2.datalabel); }
}
// pick a category
if (round.category == input.catA.datalabel)
{
round.itemtype = input.catA.itemtype;
if (i < 4) { round.correct = 1; }
else { round.correct = 2; }
// pick an item different from the last
while (prevIndexA == round.catIndex)
{ round.catIndex = Math.floor(Math.random()*input.catA.items.length); }
prevIndexA = round.catIndex;
}
else if (round.category == input.catB.datalabel)
{
round.itemtype = input.catB.itemtype;
if (i < 4) { round.correct = 2; }
else { round.correct = 1; }
// pick an item different from the last
while (prevIndexA == round.catIndex)
{ round.catIndex = Math.floor(Math.random()*input.catB.items.length); }
prevIndexA = round.catIndex;
}
else if (round.category == input.cat1.datalabel)
{
round.itemtype = input.cat1.itemtype;
round.correct = 1;
// pick an item different from the last
while (prevIndex1 == round.catIndex)
{ round.catIndex = Math.floor(Math.random()*input.cat1.items.length); }
prevIndex1 = round.catIndex;
}
else if (round.category == input.cat2.datalabel)
{
round.itemtype = input.cat2.itemtype;
round.correct = 2;
// pick an item different from the last
while (prevIndex1 == round.catIndex)
{ round.catIndex = Math.floor(Math.random()*input.cat2.items.length); }
prevIndex1 = round.catIndex;
}
roundArray[i].push(round);
}
which I changed to this :
prevIndexA = -1; prevIndexB = -1; prevIndex1 = -1; prevIndex2 = -1;
for (var j = 0; j<numrounds; j++)
{
var round = new IATround();
if (stype == "target")
{
round.category = (Math.random() < 0.5 ? input.catA.datalabel : input.catB.datalabel);
}
else if (stype == "association")
{
round.category = (Math.random() < 0.5 ? input.cat1.datalabel : input.cat2.datalabel);
}
else if (stype == "both")
{
if (j % 2 == 0) { round.category = (Math.random() < 0.5 ? input.catA.datalabel : input.catB.datalabel); }
else { round.category = (Math.random() < 0.5 ? input.cat1.datalabel : input.cat2.datalabel); }
}
// pick a category
if (round.category == input.catA.datalabel)
{
round.itemtype = input.catA.itemtype;
if (i < 4) { round.correct = 1; }
else { round.correct = 2; }
// pick an item different from the last
do
{ round.catIndex = Math.floor(Math.random()*input.catA.items.length); }
while (prevIndexA == round.catIndex);
prevIndexA = round.catIndex;
}
else if (round.category == input.catB.datalabel)
{
round.itemtype = input.catB.itemtype;
if (i < 4) { round.correct = 2; }
else { round.correct = 1; }
// pick an item different from the last
do
{ round.catIndex = Math.floor(Math.random()*input.catB.items.length); }
while (prevIndexB == round.catIndex);
prevIndexB = round.catIndex;
}
else if (round.category == input.cat1.datalabel)
{
round.itemtype = input.cat1.itemtype;
round.correct = 1;
// pick an item different from the last
do
{ round.catIndex = Math.floor(Math.random()*input.cat1.items.length); }
while (prevIndex1 == round.catIndex);
prevIndex1 = round.catIndex;
}
else if (round.category == input.cat2.datalabel)
{
round.itemtype = input.cat2.itemtype;
round.correct = 2;
// pick an item different from the last
do
{ round.catIndex = Math.floor(Math.random()*input.cat2.items.length); }
while (prevIndex2 == round.catIndex);
prevIndex2 = round.catIndex;
}
roundArray[i].push(round);
}
I'm not an experienced coder so I don't know if this didn't create other problems, but the randomization in the output looks much better now.
Thanks for this! I've made the changes in the code.