function [RTcorrect,RTincorrect]  =  expectedMeanRT(p)
% [RTcorrect,RTincorrect]  =  expectedMeanRT(p)
%
% Calculates the analytical solution for mean RT for correct and incorrect
% trials for a diffusion model with the following parameters (as fields in
% the structure 'p'):
%
% p.a  upper bound (correct answer)
% p.b  lower bound (incorrect answer)
% p.s  standard deviation of drift (units/sec)
% p.u  drift rate (units/sec)


if p.u ==0
    RTcorrect = (p.a^2+2*p.a*p.b)/(3*p.s^2);
    RTincorrect = (p.b^2+2*p.a*p.b)/(3*p.s^2);
else
    
    RTcorrect = (p.a+p.b)/p.u * coth( (p.a+p.b)*p.u/p.s^2) - ...
        p.b/p.u*coth(p.b*p.u/p.s^2);
    
    RTincorrect = (p.a+p.b)/(-p.u) * coth( (p.a+p.b)*(-p.u)/p.s^2) - ...
        p.a/(-p.u)*coth(p.a*(-p.u)/p.s^2);
    

end