Go to the documentation of this file.00001
00002
00003 DOUBLE PRECISION FUNCTION DBETAI (X, PIN, QIN)
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 DOUBLE PRECISION X, PIN, QIN, ALNEPS, ALNSML, C, EPS, FINSUM, P,
00038 1 PS, Q, SML, TERM, XB, XI, Y, D1MACH, DLBETA, P1
00039 LOGICAL FIRST
00040 SAVE EPS, ALNEPS, SML, ALNSML, FIRST
00041 DATA FIRST /.TRUE./
00042
00043 IF (FIRST) THEN
00044 EPS = D1MACH(3)
00045 ALNEPS = LOG (EPS)
00046 SML = D1MACH(1)
00047 ALNSML = LOG (SML)
00048 ENDIF
00049 FIRST = .FALSE.
00050
00051 IF (X .LT. 0.D0 .OR. X .GT. 1.D0) CALL XERMSG ('SLATEC', 'DBETAI',
00052 + 'X IS NOT IN THE RANGE (0,1)', 1, 2)
00053 IF (PIN .LE. 0.D0 .OR. QIN .LE. 0.D0) CALL XERMSG ('SLATEC',
00054 + 'DBETAI', 'P AND/OR Q IS LE ZERO', 2, 2)
00055
00056 Y = X
00057 P = PIN
00058 Q = QIN
00059 IF (Q.LE.P .AND. X.LT.0.8D0) GO TO 20
00060 IF (X.LT.0.2D0) GO TO 20
00061 Y = 1.0D0 - Y
00062 P = QIN
00063 Q = PIN
00064
00065 20 IF ((P+Q)*Y/(P+1.D0).LT.EPS) GO TO 80
00066
00067
00068
00069
00070 PS = Q - AINT(Q)
00071 IF (PS.EQ.0.D0) PS = 1.0D0
00072 XB = P*LOG(Y) - DLBETA(PS,P) - LOG(P)
00073 DBETAI = 0.0D0
00074 IF (XB.LT.ALNSML) GO TO 40
00075
00076 DBETAI = EXP (XB)
00077 TERM = DBETAI*P
00078 IF (PS.EQ.1.0D0) GO TO 40
00079 N = MAX (ALNEPS/LOG(Y), 4.0D0)
00080 DO 30 I=1,N
00081 XI = I
00082 TERM = TERM * (XI-PS)*Y/XI
00083 DBETAI = DBETAI + TERM/(P+XI)
00084 30 CONTINUE
00085
00086
00087
00088 40 IF (Q.LE.1.0D0) GO TO 70
00089
00090 XB = P*LOG(Y) + Q*LOG(1.0D0-Y) - DLBETA(P,Q) - LOG(Q)
00091 IB = MAX (XB/ALNSML, 0.0D0)
00092 TERM = EXP(XB - IB*ALNSML)
00093 C = 1.0D0/(1.D0-Y)
00094 P1 = Q*C/(P+Q-1.D0)
00095
00096 FINSUM = 0.0D0
00097 N = Q
00098 IF (Q.EQ.DBLE(N)) N = N - 1
00099 DO 50 I=1,N
00100 IF (P1.LE.1.0D0 .AND. TERM/EPS.LE.FINSUM) GO TO 60
00101 XI = I
00102 TERM = (Q-XI+1.0D0)*C*TERM/(P+Q-XI)
00103
00104 IF (TERM.GT.1.0D0) IB = IB - 1
00105 IF (TERM.GT.1.0D0) TERM = TERM*SML
00106
00107 IF (IB.EQ.0) FINSUM = FINSUM + TERM
00108 50 CONTINUE
00109
00110 60 DBETAI = DBETAI + FINSUM
00111 70 IF (Y.NE.X .OR. P.NE.PIN) DBETAI = 1.0D0 - DBETAI
00112 DBETAI = MAX (MIN (DBETAI, 1.0D0), 0.0D0)
00113 RETURN
00114
00115 80 DBETAI = 0.0D0
00116 XB = P*LOG(MAX(Y,SML)) - LOG(P) - DLBETA(P,Q)
00117 IF (XB.GT.ALNSML .AND. Y.NE.0.0D0) DBETAI = EXP(XB)
00118 IF (Y.NE.X .OR. P.NE.PIN) DBETAI = 1.0D0 - DBETAI
00119
00120 RETURN
00121 END