# Trying to script the General Beta 2 CDF in MATLAB

• Jul 17th 2011, 05:11 PM
rainer
Trying to script the General Beta 2 CDF in MATLAB
I'm having trouble scripting a function in MATLAB. The function is the General Beta of the Second Kind Cumulative Distribution Function:

$\frac{\left(\frac{(x/b)^a}{1+(x/b)^a}\right)^p}{pB(p,q)} \; _1\texttrm{F_2}\begin{bmatrix}p,1-q; & \frac{(x/b)^a}{1+(x/b)^a} \\ p+1 & \end{bmatrix}$

It involves the beta function and hypergeometric series as subroutines in the code. p,a,b,q are parameters. x is the independent variable (a 12x1 column vector in my case). The MATLAB script I've written:

term=(((x/b).^a)/(1+(x/b).^a));
F=hypergeom([p,1-q],p+1,term);
CDFGB2= (term.^p/(p*beta(p,q)))*F

The output I get is a 12x12 matrix when I should just get a 12x1 column vector.
If anyone has some insight I'd appreciate it.

Thanks
• Jul 17th 2011, 07:30 PM
CaptainBlack
Re: Trying to script the General Beta 2 CDF in MATLAB
Quote:

Originally Posted by rainer
I'm having trouble scripting a function in MATLAB. The function is the General Beta of the Second Kind Cumulative Distribution Function:

$\frac{\left(\frac{(x/b)^a}{1+(x/b)^a}\right)^p}{pB(p,q)} \; _1\texttrm{F_2}\begin{bmatrix}p,1-q; & \frac{(x/b)^a}{1+(x/b)^a} \\ p+1 & \end{bmatrix}$

It involves the beta function and hypergeometric series as subroutines in the code. p,a,b,q are parameters. x is the independent variable (a 12x1 column vector in my case). The MATLAB script I've written:

term=(((x/b).^a)/(1+(x/b).^a));
F=hypergeom([p,1-q],p+1,term);
CDFGB2= (term.^p/(p*beta(p,q)))*F

The output I get is a 12x12 matrix when I should just get a 12x1 column vector.
If anyone has some insight I'd appreciate it.

Thanks

Code:

term=(((x/b).^a)./(1+(x/b).^a)); F=hypergeom([p,1-q],p+1,term); CDFGB2= (term.^p/(p*beta(p,q))).*F
CB
• Jul 18th 2011, 12:55 PM
rainer
Re: Trying to script the General Beta 2 CDF in MATLAB
I like your style CB. You're like the Zorro of math.