function y = beta(z,w,v)
%BETA   Beta function.
%   Y = BETA(Z,W) computes the beta function for corresponding
%   elements of Z and W.  The beta function is defined as
%
%   beta(z,w) = integral from 0 to 1 of t.^(z-1) .* (1-t).^(w-1) dt.
%
%   The arrays Z and W must be real and nonnegative. Both arrays must be 
%   the same size, or either can be scalar.
%
%   Class support for inputs Z,W:
%      float: double, single
%
%   See also BETAINC, BETALN.

%   Ref: Abramowitz & Stegun, Handbook of Mathematical Functions, sec. 6.2.
%   Copyright 1984-2004 The MathWorks, Inc. 
%   $Revision: 5.10.4.3 $  $Date: 2004/12/06 16:36:20 $

if nargin<2,
  error('MATLAB:beta:NotEnoughInputs', 'Not enough input arguments.');
elseif nargin == 2
    y = exp(gammaln(z)+gammaln(w)-gammaln(z+w));
elseif nargin == 3
    warning('MATLAB:beta:ObsoleteUsage',['This usage of BETA(X,Z,W) is ' ...
            'obsolete and will be eliminated\n         in future versions.' ...
            '  Please use BETAINC(X,Z,W) instead.']);
    y = betainc(z,w,v);
end
