Assignment 7
Creating an Auditory or Visual Discrimination Experiment
The assignment is to write a Matlab program that collects data in a discrimination experiment, calculates signal detection indices for user performance, and writes a file containing the data for each participant tested. There are two general directions for this assignment. You can choose from the following options:
• Or… create a visual discrimination task where the user discriminates between two types of visually presented stimuli. You can read in Ch. 6 about the process of creating and visualizing images. You can decide what type of discrimination task to implement. For example, the task can involve discrimination of Gabor patches of different angles/ frequencies, detection of faces or other objects in noise or any other type of stimulus that you find interesting. There needs to be a distinction though between a noise trial and a signal trial.
REQUIREMENTS
• The program should first ask for the id of the user.
• The program should ask for the number of trials n in the discrimination task. The
number n should be an even number.
• The program should randomly allocate n/2 signal events and n/2 noise events to
the n trials
• The randomization should be the same for each user id. In other words, if we restart the
program with the same user id, we should get the same sequence of trials (i.e., make sure
you are setting the random seed)
• On each trial, a signal or noise event should be presented (sound or image) and the user
has to respond with a signal or noise decision using letters or numbers as responses. You do not have to implement a graphical user interface for the task. Simply use the command window to present feedback and receive user input from the keyboard.
• The user should receive feedback after each trial (correct or incorrect)
• After n trials are completed, calculate the following
1. The probability of a hit (i.e. probability that a user reports a signal when the stimulus was sampled from the signal distribution)
2. The probability of a false alarm (i.e., probability that a user reports a signal when the stimulus was sampled from the noise/standard distribution).
3. Sensitivity (d’) and the bias (beta) index from Signal Detection Theory as described on p. 183 (Ch. 7). There is a problem calculating d’ when the observed hit or false alarm rates equal 0 or 1. There are several elegant solutions to this problem (including Bayesian analysis) but we will not pursue those here. One ad- hoc solution you can use is to replace the empirical hit or false alarm rates of 0 or 1 with fixed values of 0.01 and .99 respectively.
• Show these performance numbers to the user
• The data should be saved to a .mat Matlab file. The filename should be constructed in
such a way that it is unique. The filename should have the user id in the file. Optionally, you can also put some timestamp in the name. You should save all the data that is need to reconstruct what happened in the discrimination task including all individual decisions. Also save the signal detection indices calculated at the end of the task.
Assignment 8
Creating an interactive puzzle
The assignment is to write a Matlab program that allows a user to play the 15-puzzle as well as variants of the puzzle such as the 8-puzzle, 24-puzzle, etc. A description of the 15-puzzle can be found here
(Links to an external site.)
Links to an external site.
. To get a better sense of how the game is played, play the game yourself using one of many online versions available (here is one
(Links to an external site.) Links to an external site.
).
In the 15 puzzle, there are 15 numbered square tiles with one tile missing. The missing tile allows the other tiles to be moved around. The game starts with a random ordering of the numbered tiles (see left panel below). The goal is to get the numbered tiles in order (see middle panel). On each turn, only a tile that neighbors the empty position can be moved into the empty slot.
One of the challenges of this assignment is think carefully about the representation of the missing tile. There are lots of ways to program this game. You might also consider starting just with the 15 puzzle, and then rewriting the program to solve the general n-puzzle. In my own
attempt to program this puzzle, I used the following set of Matlab commands and functions: rng, randperm, reshape, while/end, break, find, abs, fprintf, for/end, sum, and if/then.
REQUIREMENTS
• You write the program that allows a user to play the game. You do not have to write any AI engine that solves the game.
• You do not have the create a graphical user interface for this assignment. You can simply use the command window to visualize the puzzle and ask for user input. See below for an example of how the screen can look like.
• The user should first be asked the size n of the puzzle they want to play. With n=4, they would play the standard game with n2-1 = 15 numbered squares. However, you should program the game such that any n>2 are acceptable inputs. (NOTE: to simplify the program, you could first program the 15 puzzle and then later revisit this requirement for the general n-puzzle)
• Each game should start with a random configuration of the numbered tiles that is different from the goal configuration.
• At each iteration, the user is asked for their next move in terms of a number from 1… (n2-1). The program needs to prompt the user for another input if the input corresponds to an illegal move (the proposed tile does not neighbor the empty tile) or the input is a not a number.
• The program should display the number of correctly placed tiles at each iteration
• The program should stop when the solution is reached OR the user wants to stop the
game (e.g., by not entering any move).
• Your Matlab program could be written as a single .m file that has one main function and
two local functions (within the same program). Look up the Matlab documentation for a
description of local functions (also called subfunctions).
• One local function should visualize the current state of the puzzle and the number of
correctly placed tiles
• Another local function should calculate the number of corrected placed tiles
• It is likely that you will make lots of mistakes during the course of this assignment. The
best way to find problems with your program is to debug the program. When you demonstrate your program (see grading below), you will be asked to also demonstrate the ability to debug the program.
• Note that some starting positions are impossible to solve. The figure above, right panel, shows one example. Do not worry in this assignment with the problem of creating solvable problems (this will serve as an extra credit assignment)
SCREEN EXAMPLE