function F = beta_cdf( x, abqp )
% F = beta_cdf( x, [ a, b, q, p ] )
% compute the CDF of the beta probability distribution function
% in terms of it's min and max values (a,b)) and exponents (p,q) 

a = abqp(1);
b = abqp(2);
q = abqp(3);
p = abqp(4);

%minx = min(x);
%maxx = max(x);

 if (b < a)
   printf('error: beta_cdf: a = %f, b = %f, a must be less than b \n', a, b );
 end

 z = (x-a)/(b-a);
 z(find(z<0)) = 0;
 z(find(z>1)) = 1;

 F = betainc( z, q, p ); 

% beta_cdf ---------------------------------------------------- 13 Feb 2024

