Chapter 6: basic lever-pressing example
Chapter 6: basic lever-pressing example
We will perform the calculations based on observing 3 failed (no-food) lever-presses and 2 successful lever-presses in two ways. First, we will iteratively compute the evidence based on the binomial probabilities for single observations of successful and unsuccessful lever-presses (definitions given in the main text), and then we will arrive at the same result using an all-at-once calculation based on the binomial probabilities describing the full dataset under each of the two models.
%%% press-by-press calculation
dat=[0 0 1 0 1];
dEpos=10*log10(3/1); %evidence change (high-rate hypothesis) following successful press
dEneg=10*log10(7/9); %evidence change (high-rate hypothesis) following unsuccessful press
EV=0;
for i=1:length(dat),
if dat(i)==1, EV=EV+dEpos;
else EV=EV+dEneg; end, end
%%% all-at-once calculation
EV(2)=sum(dat==1)*dEpos+sum(dat==0)*dEneg;
%%% alternate all-at-once calculation
rhoH=.3; rhoL=.1;
Lh=bpdf(sum(dat),length(dat),rhoH);
Ll=bpdf(sum(dat),length(dat),rhoL);
EV(3)=10*log10(Lh/Ll);
%%% compare the three calculations
isnear(EV(1),EV(2))
isnear(EV(2),EV(3))