function [loglike, path] = lipolike(data,time,pars,fn)
odeopts=odeset('RelTol',1e-8);
% try
    if(length(pars)>3)% initial conditions are unknown 
        [time,path]=ode15s(fn.ode,time,pars(end-1:end),odeopts,pars(1:2));
    
    else% initial conditions are known, note the addition of 0 in the time
    
        [junktime,path]=ode15s(fn.ode,[0;time(:)],[100,0],odeopts,pars(1:2));
        path=path(2:end,:);%get rid of the initial condition.
        
    end
    
    
    loglike=sum(log(normpdf(path(:,1),data,sqrt(pars(3)))));
% 
% catch% it happens sometimes, if the parameter values are at the edge of a behaviour change or they model behaviour that is too steep.
%     warning('problem with the numerical integration')
%     loglike=-inf
% end
