
function [z] =  alcdf(x,mu,sigma,p)

%--------------------------------------------------------------------------
% OUTPUT
% z     : Returns the probability till point 'x'
% INPUT
% x     : x is scalar value.
% mu    : location parameter
% sigma : scale parameter
% p     : quantile or skewness parameter, p in (0,1)
%--------------------------------------------------------------------------

% check function
if p>1 || p<0
   error('p must lie between 0 and 1')
end

if x <= mu
   z = p*exp( (1-p)*( (x-mu)/sigma ))  ;
else
   z = 1 - (1-p)*exp( -p*( (x-mu)/sigma ) );
   
   % Alternatively, with mu-0, sigma=1.
   % z = p +(1-p)*( 1 - exp(-x*p) );
end

end