Home > . > qbeta.m

qbeta

PURPOSE ^

QBETA The beta inverse distribution function

SYNOPSIS ^

function x = qbeta(p,a,b)

DESCRIPTION ^

QBETA    The beta inverse distribution function

         x = qbeta(p,a,b)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x = qbeta(p,a,b)
0002 %QBETA    The beta inverse distribution function
0003 %
0004 %         x = qbeta(p,a,b)
0005 
0006 %       Anders Holtsberg, 27-07-95
0007 %       Copyright (c) Anders Holtsberg
0008 
0009 if any(any((a<=0)|(b<=0)))
0010    error('Parameter a or b is nonpositive')
0011 end
0012 if any(any(abs(2*p-1)>1))
0013    error('A probability should be 0<=p<=1, please!')
0014 end
0015 b = min(b,100000);
0016 
0017 x = a ./ (a+b);
0018 dx = 1;
0019 while any(any(abs(dx)>256*eps*max(x,1)))
0020    dx = (betainc(x,a,b) - p) ./ dbeta(x,a,b);
0021    x = x - dx;
0022    x = x + (dx - x) / 2 .* (x<0);
0023    x = x + (1 + (dx - x)) / 2 .* (x>1);
0024 end
0025 
0026

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003