% P = potSech2(s) - Sech-squared potential (Logistic distribution)
%
% pot(s) = 1 / cosh(s)^2
%
% See also POTFUNCTIONS.M.
% (c) by Hannes Nickisch, MPI for Biological Cybernetics, 2010 September 29
function P = potSech2(s,type,z)
if nargin==1
q = numel(s); P = zeros(q,4); % allocate memory, b=0
a = exp(-2*abs(s(:))); % always between 0 and 1 and therefore safe to evaluate
P(:,1) = -2*(abs(s(:)) + log(1+a) - log(2));% log potential, -2*log( cosh(s) )
b = 2*a./(1+a);
P(:,2) = -2*sign(s(:)).*(1-b); % 1st derivative of log potential
P(:,3) = -4*b./(1+a); % 2nd derivative of log potential
else
if strcmp(type,'VB')
P = potSech2(s);
elseif strcmp(type,'EP')
q = numel(s); P = zeros(q,3); % allocate memory, b=0, d2lp=0
fac = 1e1; % factor between the widths of the two distributions ...
% ... from when one considered a delta peak, we use 3 orders of magnitude
idpot = fac