function [p,b] = F_Probabilidad_Beneficio(t,a,s,c,g)

% Finds the probability and benefit of A hits in T trials
% Input:
%   t : number of trials
%   a : number of hits
%   s : hit probability
%   c : cost per trial
%   g : gain per hit
% Output:
%   p : probability of a hits in t trials
%   b : net benefit
% J.M.Soler, Oct.2018

if t>=a
    p = s^a * (1-s)^(t-a) * factorial(t) / factorial(a) / factorial(t-a);
    b = g*a-c*t;
else
    p = 0;
    b = 0;
end

end

