0

I am presenting a series of adjectives in Spanish organized into two groups; they are organized into an array. These stimuli are presented to the participant 40 times, 20 positive adjectives and 20 negative adjectives. For experimental reasons, I can only use 8 positive and 8 negative adjectives, which makes a total of 18 stimuli. I hake successfully randomized them and limited number of adjectives of each type that appear, but I have no idea how I can make the program go through the list randomly (and once all of the stimuli have been presented (again, it’s important that all of this is completely random), start over. It’s hard to explain, but for example, if I have 6 names, 3 of men and 3 of women, (Jack, John, Jacob, Ana, Stephanie and Jessica) I need my program to go randomly through those six names before it repeats a name (obviously this may happen more than once).

<code>
var estimulo = ["Incompetente" ,"Incapaz" ,"Dependiente" ,"Estúpido/a" ,"Antipático/a" ,"Frío/a" ,"Hipócrita" ,"Mala persona" ,"Competente" ,"Capaz" ,"Independiente" ,"Inteligente" ,"Amable", "Cálido/a", "Sincero/a", "Buena persona"];
<br>
    if (countere < 40) {
        if (counterd < 20 && counteri < 20) {
            var i = Math.floor((Math.random() * 16));
        } 
        else {
            if (counterd == 20) {
                var i = Math.floor((Math.random() * 8));
            } else if (counteri == 20) {
                var i = Math.floor((Math.random() * 8+8));
            }
        }
    }
</code>

This is part of the code i am using now (the experiment is much larger than this), http://jsfiddle.net/alereinel/rdUtW/

I am writing this on an HTML page using .write method and variables

Thanks for your help

  • 5
    Anytime someone needs to include "randomization without repetition" the process is to generate the range of values, then **shuffle** them randomly. Now you have an array of shuffled values that you can go through one at a time. When you reach the end, start all over, optionally shuffling the set again. – myermian Sep 17 '13 at 13:03
  • 1
    @m-y: I was just about to say that. You don't want to *randomize*; you want to *shuffle*. – cHao Sep 17 '13 at 13:04
  • okay, but how can i do that ?? Im very new at this =-S – Alejandro Reinel Sep 17 '13 at 13:05
  • 1
    Have a look at my answer here http://stackoverflow.com/questions/16117472/js-jquery-how-to-randomize-images/16117736#16117736, I called the object `ImageLoader`, but you can just rename it, it will work with any kind of items. – plalx Sep 17 '13 at 14:26

0 Answers0