function p = fdistp(f,v1,v2)
%FDISTP	FDISTP(F,V1,V2) is the probability distribution function at F
%	of the F-distribution with v1 and v2 degrees of freedom.
%	See also FDISTQ.

% Gordon Smyth, University of Queensland, gks@maths.uq.edu.au
% 5 Jun 92, 28 Jan 93, 3 Apr 97
% Reference:  Johnson & Kotz, Chapter 26, page 78.

a = v1 ./ 2;
b = v2 ./ 2;
x = v1 .* f ./ ( v2 + v1 .* f) ;
if x<=0,
   p = 0.0;
elseif x>=1;
   p = 1.0;
else
   p = betainc(x,a,b);
end
