Home Reference Source

>> Stevens

Specifications

_Note that all CAPPED variables are constants taken from the excel sheets/data file._

Practice Procedure

Test Procedure

JsPsych Timeline

- Display instructions
- Ready screen
- Display Stevens practice trials {
    For a given Stevens experiment, continue to display trials if: 
    - The person has inputted less than the value of TRIALS_PER_ROUND for a given subcondition, or, 
    - There are still more subconditions to show, or
    - The person's performance has not passed the exclusion criteria
  }  
- Stop screen
- Ready screen
- Display Stevens test trials {
    For a given Stevens experiment, continue to display trials if: 
    - The person has inputted less than the value of TRIALS_PER_ROUND for a given subcondition, or, 
    - There are still more subconditions to show
  }  
- Stop screen with data download options

Trial Logic

Within the trial object, all computations for distributions and constants are performed in the on_start() function. This means that prior to a trial executing, we perform ALL operations detailed in this function. This trial object can be found on line 123 in scripts/experiments/stevens.js.

In general, this is what is executed:

on_start: function(){

  // Retrieve the constants (i.e variables listed in the section below) for the given subcondition index i
  var constants = get_constants_for_subcondition(i); 

  // Save all relevant constants of this trial to the JsPsych data object
  handle_data_saving(constants); 

  // Update the estimated correlation
  // (Refer to next section for pseudocode of this function)
  var estimated_correlation = update_estimated_correlation(this.trial, constants, last_trial); 

  // Generate the gaussian distributions
  var high_coordinates = generate_distribution(constants.HIGH_REF, 
                                               constants.ERROR, 
                                               constants.NUM_POINTS, 
                                               constants.NUM_SD, 
                                               constants.MEAN,
                                               constants.SD);

  var high_coordinates = generate_distribution(constants.LOW_REF, 
                                               constants.ERROR, 
                                               constants.NUM_POINTS, 
                                               constants.NUM_SD, 
                                               constants.MEAN,
                                               constants.SD);

  var estimated_coordinates = generate_distribution(estimated_correlation, 
                                               constants.ERROR, 
                                               constants.NUM_POINTS, 
                                               constants.NUM_SD, 
                                               constants.MEAN,
                                               constants.SD);

  // Randomize position of the low/high correlations to be either left/right
  // and keep these positions constant for a given subcondition
  if (is_last_trial_of_subcondition(i)){
    var result = randomize_position(high_coordinates, low_coordinates);
  }

  // Set these correlations to the global D3 variables used for plotting
  left_coordinates = result.left;
  right_coordinates = result.right; 
  middle_coordinates = estimated_coordinates;

} 

Estimated Correlation

Below is the pseudocode for how the estimated correlation value is generated for a given trial.

var MAX_STEP_INTERVAL = 10;

function update_estimated_correlation(trial, constants, last_trial){

  var estimated_correlation;

  // If this is the first trial, we need to initialize the middle correlation value
  if (this_is_the_first_trial()){
    estimated_correlation = Math.random() < 0.5 ? constants.LOW_REF : constants.HIGH_REF;
    trial.data.step_size = (constants.HIGH_REF - constants.LOW_REF) / MAX_STEP_INTERVAL;
  }

  // If there was a key press in the last value, we set this current trial's middle correlation value
  // to be based on that input
  else if (last_trial.key_press != null && last_trial.key_press.is_valid_value){
    if (last_trial.key_press == UP_VALUE){
      estimated_correlation = Math.min(constants.HIGH_REF, last_trial.estimated_correlation + (Math.random() * 
      last_trial.step_size));
    }
    else if (last_trial.key_press == DOWN_VALUE){
      estimated_correlation = Math.max(constants.LOW_REF, last_trial.estimated_correlation - (Math.random() * 
      last_trial.step_size));
    }
  }

  // If there was no input in the last trial
  else {
    estimated_correlation = last_trial.estimated_correlation;
  }

  return estimated_correlation;
}

Constants

These are the constants extracted from the input excel sheets. The values of these constants differ for each sub condition.