Mathematica is capable of evaluating the incomplete beta function
$$ \mathrm{Beta}[z,a,b] = \int_0^z u^{a-1}\left(1-u\right)^{b-1}\,du $$
even when the argument $z$ is negative. MATLAB's function betainc(z,a,b), however, only allows $z\in[0,1]$. Do there exist any work-arounds for this (analytical tricks, or better MATLAB functions)?
Another possibility is to evaluate the integral that defines the incomplete beta function using quadrature. In Matlab you can use the
integralfunction (usequadgkif you have an older version of Matlab)where the output is divided by
beta(a,b)to obtain the regularized incomplete beta function matchingbetainc. This can be vectorized acrosszwithThe result is about the same speed as using
hypergeomon my computer.Also, note the complete definition of the incomplete beta function and the regularized beta function given at the functions.Wolfram.com site. For certain special combinations of parameters, both the hypergeometric form, and the equivalent integral, need to be evaluated differently. Also, Matlab's
betafunction will produce errors in these situations as well, as it's based ongammalnunder the hood in order to be numerically careful. The symbolic beta function can be used as a substitute:double(beta(sym(a),sym(b)))ormfun('beta',a,b).