function Q = cost(V,t,tc,Run)
%
% Least-squares cost function for the IL model
%
% INPUT:
% Run = stick function
% tc = time course
% t = vector of time points
% V = parameters
%
% OUTPUT:
% Q = cost
%
% By Martin Lindquist and Tor Wager
% Edited 12/12/06
%

len = length(Run);

h1 = Get_Logit(V(1:7),t);           % Get IL model corresponding to parameters V
yhat = conv(Run, h1);               % Convolve IL model with stick function
yhat = yhat(1:len);

Q = sum((yhat-tc).^2);              % Calculate cost function

return