2
real function riembi(p,q,x)
3
c implementation of Lentz's continued fraction
4
c based on ideas from Numerical Recipes (Press et. al., 1986)
6
real p,q,x,gamlog,rbfrac,zero,one,two,sav
7
parameter (zero=0.,one=1.,two=2.)
8
c Abramovitz & Stegun 1971 (26.5.8)
9
if (x.lt.zero.or.x.gt.one) then
10
cc obsolete Fortran statement: PAUSE
11
cc pause 'riembi: argument X out of range'
14
elseif (x.eq.zero.or.x.eq.one) then
17
c Abramovitz & Stegun 1971 (6.2.2)
19
$-gamlog(p)-gamlog(q)+p*log(x)+q*log(one-x))
21
c Abramovitz & Stegun 1971 (26.5.8)
22
if ((p+one)/(p+q+two).gt.x) then
23
riembi=sav*rbfrac(p,q,x)/p
25
c Abramovitz & Stegun 1971 (26.5.2)
26
riembi=one-sav*rbfrac(q,p,one-x)/q