C Version July 2007 C C The MREG module provide 3 programs. C C 1) MREG C 2) RIND C 3) FI - normal CDF C C MREG and RIND are explained in the following: C C C CALL MREG(F,R,B,DB,AA,BB,A,DA,VDER,M,N,NIT,INFR) C C F = expectation C R = Covariance R(i+(j-1)*N) = Cov( Delta(T(i)), Delta(T(j)), length RDIM (in) C B = Covariance B(i) = Cov(Delta(T(i)), XN), B(N+1)=Var(XN) length NMAX (in) C DB = Covariance DB(i) = Cov(Delta(T(i)), Y0), DB(N+1)=Cov(XN,Y0) length NMAX (in) C AA = Regression matrix coefficients size MMAX x MMAX C BB = Regression vector coefficients length MMax + 1 C A = Slepian model coefficients, length (MMax + 1) * NMAX C DA = Slepian model coefficients, length MMax + 1 C VDER = variance of Y0, Var(Y0) C M = Number of regressors ( 0 < M < MMAX) C N = dimension of the problem ( N < NMAX) C NIT = 0,1,2..., maximum # of iterations/integrations done by quadrature C to calculate the indicator function C INFR = 1 means all input are the same as in the previous call except BB, A and DA C 0 indicate new input C C The program MREG computes the following problem: C C We consider a process X(I)=X(T(I)) at the grid of N points T(1),...,T(N), C C X(I) = -A(I) + Z*A(I+N) + Sum Xj*A(I+(j+1)*N) + Delta(I), j=1,...,M-1 C C where the sum disappears if M=1. We assume that Z,Xj are independent C standard Rayleigh, Gaussian distributed rv. and independent of the zero C mean Gaussian residual process, with covariance structure given in R, C C R(i+(j-1)N) = Cov (Delta(T(i)), Delta(T(j))). C C Additionally we have a zero mean Gaussian variable XN, C independent of Z,Xj with covariance structure defined by C B(i)= Cov (Delta(T(i)),XN), i=1,...,N, B(N+1)=Var(XN). C Furthermore XN and Z,Xj satisfies the following equation system C C (BB + (XN,0,...,0)^T = AA*(Z,X1,...,Xm-1)^T (***) C C where AA is (M,M) matrix, BB is M-vector. We rewrite this equation, by C introducing a variable Xm=XN/SQRT(Var(XN)) and construct new matrix AA1 c by adding the column (SQRT(Var(XN)),0,...,0) and the row with only zeros. C The equations (***) writtes C C (BB,0)^T = AA1*(Z,X1,...,Xm-1,Xm)^T (****) C C where AA1 is (M+1,M+1) matrix, We assume that the rank of AA1 is M, C otherwise the density is singular and we give a output F=0.CC C C Let Y0 be a zero-mean Gaussian variable independent of Z,Xj C with covariance structure defined by C DB(i)= Cov (Delta(T(i)),Y0), i=1,...,N, DB(N+1)=Cov(XN,Y0), Var(Y0)=VDER. C Let Y be defined by C C Y=-DA(1) + Z*DA(2) + Sum Xj*DA(2+j) +Y0, j=1,...,M-1. C C The MREG program computes: C C F = E[ Y^+ *1{ HH0 defines integration region for X. C In the simplest case NIT=0 we define (Delta(1),...,Delta(N),Y1)=0.0d0 C For NIT=1 only (Delta(1),...,Delta(N))=0, i.e. we have to compute C a one dimensional integral. Finally by conditioning on X the problem is C put in the format of RIND-problem. C C INF indicates whether one C has already called the subroutine before and ONLY! inputs BB, DA or A C was changed. C C Observe the limitations are : N mreg and rind publicly available ! - All commonblocks are replaced with a corresponding module ! References ! Rychlik, I and Lindgren, G (1993) ! "CROSSREG - A Technique for First Passage and Wave Density Analysis" ! Probability in the Engineering and Informational Sciences, Vol 7, pp 125--148 ! ! Lindgren, G and Rychlik, I (1991) ! "Slepian Models and Regression Approximations in Crossing and xtreme value Theory", ! International Statistical Review, Vol 59, 2, pp 195--225 MODULE SIZEMOD IMPLICIT NONE INTEGER, PARAMETER :: MMAX = 6, NMAX = 201 INTEGER, PARAMETER :: RDIM = NMAX*NMAX END MODULE SIZEMOD MODULE EPSMOD IMPLICIT NONE ! Constants determining accuracy of integration !----------------------------------------------- !if the conditional variance are less than: C DOUBLE PRECISION :: EPS2=1.d-4 !- EPS2, the variable is ! considered deterministic DOUBLE PRECISION :: EPS = 1.d-2 ! SQRT(EPS2) C DOUBLE PRECISION :: XCEPS2=1.d-16 ! if Var(Xc) is less return NaN DOUBLE PRECISION :: EPSS = 5.d-5 ! accuracy of Indicator C DOUBLE PRECISION :: CEPSS=0.99995d0 ! accuracy of Indicator DOUBLE PRECISION :: EPS0 = 5.d-5 ! used in GAUSSLE1 to implicitly ! determ. # nodes C DOUBLE PRECISION :: fxcEpss=1.d-20 ! if less do not compute E(...|Xc) C DOUBLE PRECISION :: xCutOff=5.d0 ! upper/lower truncation limit of the ! normal CDF C DOUBLE PRECISION :: FxCutOff = 0.99999942669686d0 C DOUBLE PRECISION :: CFxCutOff = 5.733031438470704d-7 ! 1-FxCutOff, END MODULE EPSMOD MODULE RINTMOD DOUBLE PRECISION, save :: C = 4.5d0 DOUBLE PRECISION, save :: FC = 0.999993204653751d0 C COMMON /RINT/ C,FC END MODULE RINTMOD MODULE TBRMOD USE SIZEMOD IMPLICIT NONE DOUBLE PRECISION, DIMENSION(NMAX) :: HH END MODULE TBRMOD MODULE EXPACCMOD DOUBLE PRECISION,PARAMETER:: PMAX = 40.0d0 C COMMON /EXPACC/ PMAX END MODULE EXPACCMOD MODULE INFCMOD IMPLICIT NONE INTEGER, save :: ISQ = 0, IAC=1 INTEGER, DIMENSION(10) :: INF,INFO C DOUBLE PRECISION, DIMENSION(10):: C COMMON /INFC/ ISQ,INF,INFO END MODULE INFCMOD MODULE CHECKMOD IMPLICIT NONE C III01,III11,... - variables,counts how many times one calls C subroutine RIND0,RIND1,..., III*1 are also modified in the C subroutines RIND*. This gives us statistics over the complexity of C numerical calculations. INTEGER :: III01,III11,III21,III31,III41,III51 INTEGER :: III61,III71,III81,III91,III101 INTEGER :: III0 END MODULE CHECKMOD MODULE QUADRMOD IMPLICIT NONE ! Quadratures available: Legendre INTEGER :: I C BLOCK DATA inithermite INTEGER, PARAMETER :: NNW = 13 INTEGER, DIMENSION(25) :: NN REAL*8 Z(126),H(126) C COMMON /QUADR/ Z,H,NN,NNW c COMMON /EXPACC/ PMAX C COMMON /RINT/ C,FC C DATA NNW /13/ DATA (NN(I),I=1,NNW)/2,3,4,5,6,7,8,9,10,12,16,20,24/ C DATA PMAX/40./ C DATA C/4.5/ DATA (H(I),I=1,61)/1.0d0,1.0d0,0.555555555555556d0, * 0.888888888888889d0, * 0.555555555555556d0,0.347854845137454d0,0.652145154862546d0, * 0.652145154862546d0,0.347854845137454d0,0.236926885056189d0, * 0.478628670499366d0,0.568888888888889d0,0.478628670499366d0, * 0.236926885056189d0,0.171324492379170d0,0.360761573048139d0, * 0.467913934572691d0,0.467913934572691d0,0.360761573048139d0, * 0.171324492379170d0,0.129484966168870d0,0.279705391489277d0, * 0.381830050505119d0,0.417959183673469d0,0.381830050505119d0, * 0.279705391489277d0,0.129484966168870d0,0.101228536290376d0, * 0.222381034453374d0,0.313706645877887d0,0.362683783378362d0, * 0.362683783378362d0,0.313706645877887d0,0.222381034453374d0, * 0.101228536290376d0,0.081274388361574d0,0.180648160694857d0, * 0.260610696402935d0,0.312347077040003d0,0.330239355001260d0, * 0.312347077040003d0,0.260610696402935d0,0.180648160694857d0, * 0.081274388361574d0,0.066671344308688d0,0.149451349150581d0, * 0.219086362515982d0,0.269266719309996d0,0.295524224714753d0, * 0.295524224714753d0,0.269266719309996d0,0.219086362515982d0, * 0.149451349150581d0,0.066671344308688d0,0.047175336386512d0, * 0.106939325995318d0,0.160078328543346d0,0.203167426723066d0, * 0.233492536538355d0,0.249147048513403d0,0.249147048513403d0/ DATA (H(I),I=62,101)/0.233492536538355d0,0.203167426723066d0, * 0.160078328543346d0,0.106939325995318d0, * 0.047175336386512d0,0.027152459411754094852d0, * 0.062253523938647892863d0,0.095158511682492784810d0, * 0.124628971255533872052d0,0.149595988816576732081d0, * 0.169156519395002538189d0,0.182603415044923588867d0, * 0.189450610455068496285d0,0.189450610455068496285d0, * 0.182603415044923588867d0,0.169156519395002538189d0, * 0.149595988816576732081d0,0.124628971255533872052d0, * 0.095158511682492784810d0,0.062253523938647892863d0, * 0.027152459411754094852d0,0.017614007139152118312d0, * 0.040601429800386941331d0,0.062672048334109063570d0, * 0.083276741576704748725d0,0.101930119817240435037d0, * 0.118194531961518417312d0,0.131688638449176626898d0, * 0.142096109318382051329d0,0.149172986472603746788d0, * 0.152753387130725850698d0,0.152753387130725850698d0, * 0.149172986472603746788d0,0.142096109318382051329d0, * 0.131688638449176626898d0,0.118194531961518417312d0, * 0.101930119817240435037d0,0.083276741576704748725d0, * 0.062672048334109063570d0,0.040601429800386941331d0/ DATA (H(I),I=102,126)/0.017614007139152118312d0, * 0.012341229799987199547d0, 0.028531388628933663181d0, * 0.044277438817419806169d0, 0.059298584915436780746d0, * 0.073346481411080305734d0, 0.086190161531953275917d0, * 0.097618652104113888270d0, 0.107444270115965634783d0, * 0.115505668053725601353d0, 0.121670472927803391204d0, * 0.125837456346828296121d0, 0.127938195346752156974d0, * 0.127938195346752156974d0, 0.125837456346828296121d0, * 0.121670472927803391204d0, 0.115505668053725601353d0, * 0.107444270115965634783d0, 0.097618652104113888270d0, * 0.086190161531953275917d0, 0.073346481411080305734d0, * 0.059298584915436780746d0, 0.044277438817419806169d0, * 0.028531388628933663181d0, 0.012341229799987199547d0/ DATA (Z(I),I=1,58)/-0.577350269189626d0,0.577350269189626d0, * -0.774596669241483d0,0.0d0, * 0.774596669241483d0, -0.861136311594053d0, -0.339981043584856d0, * 0.339981043584856d0, 0.861136311594053d0, -0.906179845938664d0, * -0.538469310105683d0,0.0d0, * 0.538469310105683d0, 0.906179845938664d0, -0.932469514203152d0, * -0.661209386466265d0, -0.238619186083197d0, 0.238619186083197d0, * 0.661209386466265d0, 0.932469514203152d0, -0.949107912342759d0, * -0.741531185599394d0, -0.405845151377397d0, 0.0d0, * 0.405845151377397d0, 0.741531185599394d0, 0.949107912342759d0, * -0.960289856497536d0, -0.796666477413627d0, -0.525532409916329d0, * -0.183434642495650d0, 0.183434642495650d0, 0.525532409916329d0, * 0.796666477413627d0, 0.960289856497536d0, -0.968160239507626d0, * -0.836031107326636d0, -0.613371432700590d0, -0.324253423403809d0, * 0.0d0, * 0.324253423403809d0, 0.613371432700590d0, 0.836031107326636d0, * 0.968160239507626d0, -0.973906528517172d0, -0.865063366688985d0, * -0.679409568299024d0, -0.433395394129247d0, -0.148874338981631d0, * 0.148874338981631d0, 0.433395394129247d0, 0.679409568299024d0, * 0.865063366688985d0, 0.973906528517172d0, -0.981560634246719d0, * -0.904117256370475d0, -0.769902674194305d0, -0.587317954286617d0/ DATA (Z(I),I=59,99)/-0.367831498198180d0, -0.125233408511469d0, * 0.125233408511469d0, 0.367831498198180d0, * 0.587317954286617d0, 0.769902674194305d0, * 0.904117256370475d0, 0.981560634246719d0, * -0.989400934991649932596d0, * -0.944575023073232576078d0, -0.865631202387831743880d0, * -0.755404408355003033895d0, -0.617876244402643748447d0, * -0.458016777657227386342d0, -0.281603550779258913230d0, * -0.095012509837637440185d0, 0.095012509837637440185d0, * 0.281603550779258913230d0, 0.458016777657227386342d0, * 0.617876244402643748447d0, 0.755404408355003033895d0, * 0.865631202387831743880d0, 0.944575023073232576078d0, * 0.989400934991649932596d0, -0.993128599185094924786d0, * -0.963971927277913791268d0, -0.912234428251325905868d0, * -0.839116971822218823395d0, -0.746331906460150792614d0, * -0.636053680726515025453d0, -0.510867001950827098004d0, * -0.373706088715419560673d0, -0.227785851141645078080d0, * -0.076526521133497333755d0, 0.076526521133497333755d0, * 0.227785851141645078080d0, 0.373706088715419560673d0, * 0.510867001950827098004d0, 0.636053680726515025453d0, * 0.746331906460150792614d0, 0.839116971822218823395d0/ DATA (Z(I),I=100,126)/0.912234428251325905868d0, * 0.963971927277913791268d0, 0.993128599185094924786d0, * -0.995187219997021360180d0, -0.974728555971309498198d0, * -0.938274552002732758524d0, -0.886415527004401034213d0, * -0.820001985973902921954d0, -0.740124191578554364244d0, * -0.648093651936975569252d0, -0.545421471388839535658d0, * -0.433793507626045138487d0, -0.315042679696163374387d0, * -0.191118867473616309159d0, -0.064056892862605626085d0, * 0.064056892862605626085d0, 0.191118867473616309159d0, * 0.315042679696163374387d0, 0.433793507626045138487d0, * 0.545421471388839535658d0, 0.648093651936975569252d0, * 0.740124191578554364244d0, 0.820001985973902921954d0, * 0.886415527004401034213d0, 0.938274552002732758524d0, * 0.974728555971309498198d0, 0.995187219997021360180d0/ END MODULE QUADRMOD C MODULE MREGMOD IMPLICIT NONE PRIVATE PUBLIC :: RIND, MREG, FI INTERFACE RIND MODULE PROCEDURE RIND END INTERFACE INTERFACE MREG MODULE PROCEDURE MREG END INTERFACE INTERFACE FI MODULE PROCEDURE FI END INTERFACE INTERFACE C1_C2 MODULE PROCEDURE C1_C2 END INTERFACE INTERFACE GAUSS1 MODULE PROCEDURE GAUSS1 END INTERFACE INTERFACE GAUSINT MODULE PROCEDURE GAUSINT END INTERFACE INTERFACE PYTHAG MODULE PROCEDURE PYTHAG END INTERFACE CONTAINS SUBROUTINE RIND(XIND,R,BU,DBUN,DB,SQ,VDER,NIT,N,INFR) USE TBRMOD USE INFCMOD USE CHECKMOD USE EPSMOD USE SIZEMOD IMPLICIT NONE REAL*8, intent(inout) :: XIND,DBUN,VDER REAL*8, DIMENSION(RDIM), intent(inout) :: R REAL*8, DIMENSION(NMAX), intent(inout) :: BU,DB, SQ INTEGER, intent(in) :: NIT,N,INFR REAL*8 SDER INTEGER, save :: NNIT INTEGER I,III C DIMENSION R(1),BU(1),SQ(1),DB(1) C DIMENSION INF(10),INFO(10),HH(101) C COMMON /TBR/ HH C COMMON /INFC/ ISQ,INF,INFO C COMMON /CHECK1/ III01,III11,III21,III31,III41,III51 C *,III61,III71,III81,III91,III101 C COMMON /EPS/ EPS,EPSS,CEPSS C C III01,III11,... - variables,counts how many times one calls C subroutine RIND0,RIND1,..., III*1 are also modified in the C subroutines RIND*. This gives us statistics over the complexity of C numerical calculations. C XIND=0.0d0 IF (N.lt.1) go to 99 IF (INFR.EQ.0) THEN NNIT=MIN(NIT,N) if (NNIT.gt.10) NNIT=10 DO I=1,10 INF(I)=0 INFO(I)=0 enddo III=0 DO I=1,N IF (SQ(I).GT.EPS) then III=1 else IF(BU(I).GT.0.0d0) THEN RETURN END IF IF(BU(I).LT.HH(I)) THEN RETURN END IF END IF enddo END IF IF (III.eq.0) go to 99 ! GO TO (10,20,30,40,50,60,70,80,90,100) NNIT SELECT CASE (NNIT) CASE (1) CALL RIND1(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii11=iii11+1 CASE(2) CALL RIND2(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii21=iii21+1 CASE(3) CALL RIND3(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii31=iii31+1 CASE(4) CALL RIND4(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii41=iii41+1 CASE(5) CALL RIND5(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii51=iii51+1 CASE(6) CALL RIND6(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii61=iii61+1 CASE(7) CALL RIND7(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii71=iii71+1 CASE(8) CALL RIND8(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii81=iii81+1 CASE (9) CALL RIND9(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii91=iii91+1 CASE (10) CALL RIND10(XIND,R,BU,DBUN,DB,SQ,VDER,N) iii101=iii101+1 CASE DEFAULT CALL RIND0(XIND,BU,DBUN,VDER,N) iii01=iii01+1 END SELECT RETURN 99 continue SDER=0.0d0 IF(VDER.GT.EPS) SDER=SQRT(VDER) XIND=PMEAN(DBUN,SDER) return END SUBROUTINE RIND SUBROUTINE RIND0(XIND,BU,DBUN,VDER,N) USE TBRMOD USE EPSMOD USE SIZEMOD IMPLICIT NONE INTEGER, intent(in) :: N REAL*8, intent(inout) :: XIND,DBUN,VDER REAL*8, DIMENSION(NMAX), intent(inout) :: BU REAL*8 SDER INTEGER I ! DIMENSION BU(NMAX) C DIMENSION HH(101) C COMMON /EPS/ EPS,EPSS,CEPSS C COMMON /TBR/ HH IF (N.LT.1) GO TO 20 XIND=0.0d0 IF(DBUN.LT.0.0d0) THEN RETURN END IF DO I=1,N IF(BU(I).GT.0.0d0) THEN RETURN END IF IF(BU(I).LT.HH(I)) THEN RETURN END IF enddo 20 CONTINUE SDER=0.0d0 IF(VDER.GT.EPS) SDER=SQRT(VDER) XIND=PMEAN(DBUN,SDER) RETURN END SUBROUTINE RIND0 SUBROUTINE RIND1(XIND,R,BU,DBUN,DB,SQ,VDER,N) USE SIZEMOD USE TBRMOD USE INFCMOD USE CHECKMOD USE EPSMOD USE RINTMOD IMPLICIT NONE REAL*8, intent(inout) :: XIND,DBUN,VDER REAL*8, DIMENSION(RDIM), intent(inout) :: R REAL*8, DIMENSION(NMAX), intent(inout) :: BU,DB,SQ INTEGER, intent(in) :: N REAL*8, DIMENSION(NMAX), save :: B1,SQ1 REAL*8, DIMENSION(24) :: XX1, H1 REAL*8 XMI,XMA,DER,SDER REAL*8, save :: DB1N,SDER1,VDER1, SS0 REAL*8 XFF,XF,X,XH, SQ0, HHB INTEGER I,III,J,II0,N1 ! INTEGER IAC,N ! real*8 XIND,R,BU,DBUN,DB,SQ,VDER ! REAL*8 XX1,H1, B1,SQ1,XMI,XMA, SDER,DB1N , DER, SDER1 ! REAL*8 XFF,X, XH, SQ0, HHB, SS0, VDER1, XF ! INTEGER I,J,III,II0,N1 C DIMENSION R(1),BU(1),SQ(1),DB(1),B1(NMAX),SQ1(NMAX) ! DIMENSION R(RDIM),BU(NMAX),SQ(NMAX),DB(NMAX) ,B1(NMAX),SQ1(NMAX) ! DIMENSION XX1(24),H1(24) C DIMENSION HH(101),INF(10),INFO(10) C COMMON /EPS/ EPS,EPSS,CEPSS C COMMON /RINT/ C,FC C COMMON /TBR/ HH C COMMON /INFC/ ISQ,INF,INFO C COMMON /CHECK1/ III01,III11,III21,III31,III41,III51 C *,III61,III71,III81,III91,III101 c print *,'Topp of R1:',sq(1),sq(2),sq(3) XIND=0.0d0 C Choice of the time for conditioning, two methods C C ISQ=1; INF(1)=II0 is the point where the SQ(I) obtaines its maximum, SQ0 C is the maximal st. deviation of the residual. C C ISQ=0; INF(1) is the time point when the probability P(hhXMA or X(INF(1))EPS) THEN XR1=R1(I+(I-1)*N) c IF(XR1.LT.0.0d0) CALL ERROR(I,N,-1) SQ1(I)=0.0d0 IF (XR1.GT.EPS) SQ1(I)=SQRT(XR1) ENDIF ENDDO DO I=1,N B1(I)=B1(I)/SQ0 ENDDO 99 CONTINUE C C *********************************************************** C C We shall condition on the values of X, XMIEPS) THEN XR1=R1(I+(I-1)*N) c IF(XR1.LT.0.0d0) CALL ERROR(I,N,-1) SQ1(I)=0.0d0 IF (XR1.GT.EPS) SQ1(I)=SQRT(XR1) ENDIF ENDDO DO I=1,N B1(I)=B1(I)/SQ0 ENDDO 99 CONTINUE C C *********************************************************** C C We shall condition on the values of X, XMI0 or C C b) BU(I)+x*B1(I)+C*SQ(I)XMAX in GAUSS1 - stop!' C STOP END IF NNN=0 DO I=1,NNW N=NN(I) DO J=1,N XX1(J)=0.5d0*(Z(NNN+J)*(XMA-XMI)+XMA+XMI) Z1(J)=XX1(J)*XX1(J) H1(J)=0.5d0*SP*(XMA-XMI)*H(NNN+J)*EXP(-0.5d0*Z1(J)) ENDDO NNN=NNN+N SDOT=GAUSINT(XMI,XMA,0.0d0,1.0d0,0.0d0,1.0d0) SDOT1=0.d0 DO I1=1,N SDOT1=SDOT1+Z1(I1)*H1(I1) ENDDO DIFF1=ABS(SDOT-SDOT1) IF(EPS0.LT.DIFF1) GO TO 10 III0=III0+N C PRINT *,'N. of nodes',III0 RETURN 10 CONTINUE ENDDO END SUBROUTINE GAUSS1 SUBROUTINE M_COND(Syy_cd,Syyii,Syx_cd,Syy,Syx,ii,N) C C INPUT: C C ii IS THE INDEX OF THE TIME ON WHICH WE ARE CONDITIONING. C N number of variables in covariance matrix Syy C C Covariance matrix Syy(I+(J-1)*N)=Cov(Yi,Yj) (is unchanged) C Covariance vector Syx(I)=Cov(Yi,X) (is unchanged) C C OUTPUT: C C Covariance matrix Syy_cd(I+(J-1)*N)=Cov(Xi,Xj|Xii) C Covariance vector Syyii(I)=Cov(Xi,Xii) C Covariance vector Syx_cd(I)=Cov(Xi,Y|Xii) C Variance Q1=Var(Xii)=Syyii(ii) c Obs. If Q1 C 4.5. Under we have a table with C exact values of FIFUNK. C C x FIFUNK(x) C C -5.0 0.00000005233 C -4.5 0.00000069515 C -4.0 0.00000711075 C 4.0 4.00000700000 C 4.5 4.50000100000 C C Obviously the tresholds -4.5 and 4.5 can be increased. C C IMPLICIT NONE REAL*8, intent(in) :: XX, SS REAL*8 X,Y,W,Z REAL*8, parameter :: SP = 0.398942280401433d0 IF(XX.LT.4.5d0*SS) GO TO 1 PMEAN=XX RETURN 1 IF(XX.GT.-4.5d0*SS) GO TO 3 PMEAN=0.0d0 RETURN 3 continue if (SS .LT. 0.0000001d0) then PMEAN=0.0d0 RETURN end if X=XX/SS IF(X==0) goto 8 Y=0.5d0*ABS(X) IF(Y<1.0d0) then W=Y*Y Z=((((((((0.000124818987d0*W-0.001075204047d0)*W 1 +0.005198775019d0)*W-0.019198292d0)*W+0.05905403564d0)*W 2 -0.15196875136d0)*W+0.3191529327d0)*W-0.5319230073d0)*W 3 +0.7978845606d0)*Y*2.0d0 else Y=Y-2.0d0 Z=(((((((((((((-0.000045255659d0*Y+0.00015252929d0)*Y * -0.000019538132d0)*Y-0.000676904986d0)*Y 1 +0.001390604284d0)*Y-0.000794620820d0)*Y 2 -0.002034254874d0)*Y+0.006549791214d0)*Y-0.010557625006d0)*Y+ 3 0.011630447319d0)*Y-0.009279453341d0)*Y+0.005353579108d0)*Y- 4 0.002141268741d0)*Y+0.000535310849d0)*Y+0.9999366575d0 endif IF(X.GT.0.0d0) PMEAN=SS*SP*EXP(-0.5d0*X*X)+XX*0.5d0*(Z+1.0d0) IF(X.LT.0.0d0) PMEAN=SS*SP*EXP(-0.5d0*X*X)+XX*0.5d0*(1.0d0-Z) RETURN 8 PMEAN=SS*SP RETURN END FUNCTION PMEAN REAL*8 FUNCTION FI(XX) C C Algorithm 209 from CACAM. C FI(xx) is a distribution functions of N(0,1) variable. C IMPLICIT NONE REAL*8, intent(in) :: XX REAL*8 X, Y,Z, W X=XX IF(X==0) then FI=0.5d0 RETURN endif Y=0.5d0*ABS(X) IF(Y>3.0d0) then IF(X.GT.0.0d0) FI=1.0d0 IF(X.LT.0.0d0) FI=0.0d0 RETURN endif IF (Y<1.0d0) then W=Y*Y Z=((((((((0.000124818987d0*W-0.001075204047d0)*W 1 +0.005198775019d0)*W-0.019198292d0)*W+0.05905403564d0)*W 2 -0.15196875136d0)*W+0.3191529327d0)*W-0.5319230073d0)*W 3 +0.7978845606d0)*Y*2.0d0 ELSE Y=Y-2.0d0 Z=(((((((((((((-0.000045255659d0*Y+0.00015252929d0)*Y 1 -0.000019538132d0)*Y-0.000676904986d0)*Y+0.001390604284d0)*Y 2 -0.000794620820d0)*Y-0.002034254874d0)*Y+0.006549791214d0)*Y 3 -0.010557625006d0)*Y+0.011630447319d0)*Y-0.009279453341d0)*Y 4 +0.005353579108d0)*Y-0.002141268741d0)*Y+0.000535310849d0)*Y 5 +0.9999366575d0 endif 100 IF(X.GT.0.0d0) FI=0.5d0*(Z+1.0d0) IF(X.LT.0.0d0) FI=0.5d0*(1.0d0-Z) RETURN END FUNCTION FI C Version 1991-XII-14 C The MREG program. C C C We consider a process X(I)=X(T(I)) at the grid of N points T(1),...,T(N), C C X(I) = -A(I) + Z*A(I+N) + Sum Xj*A(I+(j+1)*N) + Delta(I), C C the sum disapears if M=1, j=1,...,M-1. We assume that Z,Xj are independend C standart Rayleigh, Gaussian distributed rv. and independent of the zero C mean Gaussian residual process, with covariance structure given in R, C C R(i+(j-1)N) = Cov (Delta(T(i)), Delta(T(j))). C C Additionally we have a zero mean Gaussian variable XN, C independent of Z,Xj with covariance structure defined by C B(i)= Cov (Delta(T(i)),XN), i=1,...,N, B(N+1)=Var(XN). C Furthermore XN and Z,Xj satisfies the following equation system C C (BB + (XN,0,...,0)^T = AA*(Z,X1,...,Xm-1)^T (***) C C where AA is (M,M) matrix, BB is M-vector. We rewrite this equation, by C introducing a variable X_M=XN/SQRT(XN) and construct new matrix AA1 c by adding the column (SQRT(Var(XN)),0,...,0) and the row with only zeros. C The equations (***) writtes C C (BB,0)^T = AA1*(Z,X1,...,Xm-1,Xm)^T (****) C C where AA1 is (M+1,M+1) matrix, We assume that the rank of AA1 is M, C otherwise the density is singular and we give a output F=0.CC C C Let Y0 be a zero-mean Gaussian variable independent of Z,Xj C with covariance structure defined by C DB(i)= Cov (Delta(T(i)),Y0), i=1,...,N, DB(N+1)=Cov(XN,Y0), Var(Y0)=VDER. C Let Y be defined by C C Y=-DA(1) + Z*DA(2) + Sum Xj*DA(2+j) +Y0, C C j=1,...,M-1. The program computes: C C F = E[ Y^+ *1{ HH0 defines integration region for X. C In the simplest case NIT=0 we define (Delta(1),...,Delta(N),Y1)=0.0d0 C For NIT=1 only (Delta(1),...,Delta(N))=0, i.e. we have to compute C a one dimensional integral. Finally by conditioning on X the problem is C put in the format of RIND-problem. C C INF indicates whether one C has already called the subroutine before and ONLY! inputs BB, DA or A C was changed. C C Observe the limitations are : N<=100, 00 c IF (NNIT.GT.1) THEN DO I=1,N XR1=R(I+(I-1)*N)-B(I)*(B(I)/QD) IF(XR1.GT.EPS) THEN SQ(I)=SQRT(XR1) ENDIF ENDDO DO I=1,N DO J=1,N R1(J+(I-1)*N)=R(J+(I-1)*N)-B(I)*(B(J)/QD) ENDDO ENDDO END IF 105 CONTINUE if (idet.gt.1) return C C Renormalization is done C CALL R_ORT(CC,PC,PD,U1,V1,W1,AO,BB,A1,A0,B0,DA0,D0,DET1,M+1,N) IF(CC.LT.0.0d0) RETURN XMI=-C XMA= C IF(ABS(PD).LE.EPS.AND.PC.LT.0.0d0) RETURN IF(ABS(PD).LE.EPS) GO TO 102 X=-PC/PD IF(PD.GT.0.0d0.AND.XMI.LT.X) XMI=X IF(PD.LT.0.0d0.AND.XMA.GT.X) XMA=X 102 CONTINUE c PRINT *,'XMI,XMA',XMI,XMA IF(NNIT.eq.1.AND.IAC.LT.1.OR.NNIT.eq.0.OR.XMI.GE.XMA) THEN CALL C1_C2(XMI,XMA,A0,B0,D0(1),D0(2),0.0d0,SQ,N) c PRINT *,'XMI,XMA',XMI,XMA F=GAUSINT(XMI,XMA,D0(1),D0(2),PC,PD)*CC c print *,'return',f,cc RETURN END IF C C *********************************************************** C C We shall condition on the values of X, XMI