Computational Vision
U. Minn. Psy 5036

Try your luck against the Ideal Observer for discriminating dot density: Yes/no task

Set up a mini-experiment

Let's pretend that photons are like dots. In 1977, Barlow published a paper which did just that. He pointed out that humans can efficiently, but not perfectly, discriminate between patterns of differing dot density. He attributed the inefficiency to limitations in processing by the central rather than peripheral visual system.

Let's define a Poisson distribution with a mean of mean, with a function to draw a sample from this distribution. Let highmean = 220 for the "high" setting, and lowmean =200 for the "low" setting.  Then let's initialize an array called data, to accumulate the human, ideal, and true answers, and the corresponding hit, false alarm, correct rejection (cr), and miss events.

dotsize = 0.01;

numberofphotons[mean_] := RandomInteger[PoissonDistribution[mean]];
highmean = 220;lowmean =100;
criterion =N[ -((-highmean+lowmean)/(Log[highmean]-Log[lowmean]))]; (*We'll learn about this in the next lecture*)
data={{"myanswer","idealanswer","trueanswer","ideal hit?", "my hit?", "ideal false alarm?","my false alarm?","ideal cr?","my cr?","ideal miss?","my miss?"}};

We'll define a blank screen to turn the display on and off. Set the variable flash to blank.

blank=Graphics[{PointSize[dotsize],Black,Point/@{{},{}}},AspectRatio->1,Frame->False,FrameTicks->None,Background->GrayLevel[0.0],PlotRange->{{-0.2,1.2},{-0.2,1.2}}];
flash=blank;

Now create a window whose contents contain the graphics structure "flash". We make flash dynamic so that the display will get automatically updated whenever we change the value of flash.

nb3=CreateWindow[DocumentNotebook[Dynamic[flash]],ShowCellBracket->False,WindowSize->{300,300},WindowElements->{},Background->Black,NotebookFileName->"Yes/No Flash Display",WindowMargins->{{600,200},{120,120}}];

Define a trial that shows one flash, either high or low

Now, randomly turn the switch to "high" or "low", draw a sample. We put in a dialog box  so that you can input your response (click"yes" for "high" and  "no" for "low).

oneflash := Module[{sample,idealanswer},whichflash=RandomInteger[{0,1}];
If[whichflash==1,numsample=numberofphotons[highmean],numsample=numberofphotons[lowmean]];
sample=Table[RandomReal[{0,1},2],{numsample}];
flash=Graphics[{PointSize[dotsize],Red,Point/@sample},AspectRatio->1,Frame->False,FrameTicks->None,Background->GrayLevel[0.0],PlotRange->{{-0.2,1.2},{-0.2,1.2}}];
Pause[.5];
flash=blank;
myanswer=ChoiceDialog["High dot mean?",{"yes"->1,"no"->0},WindowMargins->{{570,100},{120,120+300}}];
idealanswer=If[numsample>criterion,1,0];
trueanswer=whichflash;
data=Append[data,{myanswer,idealanswer,trueanswer,If[idealanswer==1&&trueanswer==1,1,""],If[myanswer==1&&trueanswer==1,1,""],If[idealanswer==1&&trueanswer==0,1,""],If[myanswer==1&&trueanswer==0,1,""],If[idealanswer==0&&trueanswer==0,1,""],If[myanswer==0&&trueanswer==0,1,""],If[idealanswer==0&&trueanswer==1,1,""],If[myanswer==0&&trueanswer==1,1,""]}];];

Practice run

Let's run 20 practice runs with highmean = 220; lowmean = 100;

For[iter=0,iter<20,iter++,oneflash]

Display the data

Style[TableForm[data],FontSize->9]

Analyze the data

Let's drop the table heading stored in row 1, and then transpose the matrix so that the columns become the rows:

data2=Transpose[Drop[data,1]]

Let's use a combination of Map[ ] and Count[ ] (used earlier to make histograms) to count up all occurrences of  an event type. So the total for myhits is:

Map[Count[data2[[5]],#]&,{1}]

The total times the signal was presented (i.e. switch set to high) is:

Map[Count[data2[[3]],#]&,{1}]

So what is your hit rate?

Now let's do it “for real”, where we make the task hard, but doable--100  runs with highmean = 220; lowmean = 200;

To do it for real, you need to make the cell below Evaluatable. (Go to Cell/Cell Properties in the menu)

highmean = 220;lowmean =200;
criterion =N[ -((-highmean+lowmean)/(Log[highmean]-Log[lowmean]))];
data={{"myanswer","idealanswer","trueanswer","ideal hit?", "my hit?", "ideal false alarm?","my false alarm?","ideal cr?","my cr?","ideal miss?","my miss?"}};
For[iter=0,iter<100,iter++,oneflash]

Exercise: Lecture 4 describes a summary measure of performance that takes into account false alarm and hit rates: d'for human =z(false alarm rate for human)-z( hit rate for human)

From your measured hit and false alarm rates, calculate your d’. Compare your d’ with the ideal’s.