function value = FitGPLeftTail(beta, a1, a2, Qa1, Qa2, fQa1, fQa2)
% function that fits left tail of distribution to generalizex extreme value
% distribution

% a0: higher value (0.05)
% a1: lower value (0.02)
% Ka0: quantile of higher value
% Ka1: quantile of smaller value
% fKa0: prob of higher value
% fKa1: probability of smaller value

phi = beta(1);
sigma = beta(2);

value = (0.05*gppdf(-Qa1,phi,sigma,-Qa1) - fQa1)^2 + ...
    (0.05*gppdf(-Qa2,phi,sigma,-Qa1) - fQa2)^2;


if sigma < 0 | isreal(value) == 0
    value = 1e100;
end


