This release comes with a few new features – shuffle(), repeat(), and .Next:

  • It is now possible to create a collection of repeated items using the repeat() function.   Users of R will know how useful this can be, but I’ve included a short demo down below.
  • It is also now very easy to randomly mix-up a collection using the shuffle() function.  This could be useful for card game experiments, and I’ve also used it in the demo below.
  • We’ve added the ability to loop over a collection getting the next item from the collection which is really handy.
  • Finally, we fixed a small bug where it was not possible to load an Experimenter with a blank name.


Okay, the demo of all three of our new features!  Imagine a researcher want to run a trial 100 times, with each trial using one of two different phases called A and B.  Traditionally the researcher would use the random() function to decide which type of phase to run:

You can then run the trial 100 times, and you’ll have some random and roughly equal number of A and B phases run as part of the experiment.

However – more than one researcher wanted to have exactly 50 A phases and exactly 50 B phases in a random order.  The above code might give you 48 A phases and 52 B phases, because it’s random.  The new features let you easily have exactly 50 A and 50 B phases.

First, outside of the trial definition we’ll predetermine our 100 random phases of exactly 50 A and 50 B phases by creating two collections – the first contains 50 zeros, and the second collection contains 50 ones.  Then, we union the two collections together to have a collection of 100 items – 50 zeros followed by 50 ones ( As + Bs ).  Finally, we shuffle that collection up randomly to create our random mix of ones and zeros (which we’ll map to A phases and B phases).  So here’s the code we use outside the trial:

We want to do this outside the trial, because if we did it inside the trial we would be re-shuffling the list for each run of the trial within the experiment, removing our desired 50/50 split.

Now, our ChooseTrialTypePhase is almost identical, but instead of using random() it uses phases.Next:

Because we pre-created 50 ones and 50 zeros and then mixed them up together, we have a predetermined but random stream of exactly 50 ones and 50 zeros driving our 100 trials.

Of course, you can use this for many other things as well, and we are all looking forward to seeing how you use it.

I hope that helps,