Skip to content

How to randomize subset of trials without any trial in the subset repeating? #733

Discussion options

You must be logged in to vote

Are you looking for something like this?

var test_procedure = {
  timeline: [likert_trial, multi_select, text_page],
  sample: {
    type: "custom",
    fn: function(samples) {
      function popOneOff() {
        var rand_index = Math.round(Math.random() * (samples.length - 1));
        var item = samples[rand_index];
        samples.splice(rand_index, 1);
        return item;
      }

      return [
        0,
        1,
        popOneOff(),
        3,
        popOneOff(),
        5,
        6,
        popOneOff(),
        8,
        9,
        popOneOff(),
        11
      ];
    }
  },
  timeline_variables: [
    {
      audio: "sound/condition1/01.wav",
      trans:
        "Allie: W…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@jodeleeuw
Comment options

@jodeleeuw
Comment options

@vijaymarupudi
Comment options

@laurenbigelow
Comment options

Answer selected by jodeleeuw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #733 on June 01, 2020 15:39.