function value = i4_binomial_pdf ( n, p, k )

%*****************************************************************************80
%
%% i4_binomial_pdf() evaluates the binomial PDF.
%
%  Discussion:
%
%    pdf(n,p,k) = C(n,k) p^k (1-p)^(n-k)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 January 2021
%
%  Author:
%
%    John Burkardt.
%
%  Input:
%
%    integer N, the number of binomial trials.
%    0 < N.
%
%    real P, the probability of a success in one trial.
%
%    integer K, the number of successes.
%
%  Output:
%
%    real VALUE, the probability of K successes
%    in N trials with a per-trial success probability of P.
%
  if ( k < 0 )
    value = 0.0;
  elseif ( k <= n )
    value = nchoosek ( n, k ) * p ^ k * ( 1.0 - p ) ^ ( n - k );
  else
    value = 0.0;
  end

  return
end
