must restrict p2 such that a>0 and b>0 ....
0001 function e = fbeta(p2,p,p1,perc) 0002 % must restrict p2 such that a>0 and b>0 .... 0003 a = (1-p1)*p1^2/p2^2 - p1; 0004 b = a*(1/p1 - 1); 0005 0006 e = p - pbeta(perc,a,b);