Hi, I have the below code and want to confirm if the correlation formula matches the code..
newnum = num do 10 i=1,num
if(val1(i) .le. -999.000 .or. val2(i) .le. -999.000 ) then
newnum = newnum - 1
goto 10
endif
sumx = sumx + val1(i)
sumy = sumy + val2(i)
sumxy = sumxy + val1(i)*val2(i)
sumx2 = sumx2 + val1(i)**2
sumy2 = sumy2 + val2(i)**2
10 continue
if(newnum .le. 0) then
type *,' '
type *,'gbicorcoef - newnum = ',newnum
type *,' '
rcode = 2
return
endif
corcoef = newnum*sumxy - sumx*sumy
if((newnum*sumx2-sumx**2)*(<wbr>newnum*sumy2-sumy**2) .le. 0) then
type *,'gbicorcoef - trying sqrt on ',
+ (newnum*sumx2-sumx**2)*(<wbr>newnum*sumy2-sumy**2)
corcoef = -999.999
goto 9999
endif
corcoef =
+ corcoef/sqrt((newnum*sumx2-<wbr>sumx**2)*(newnum*sumy2-sumy**<wbr>2))
Correlation formula: [ NΣXY - (ΣX)(ΣY) / Sqrt([NΣX<sup>2</sup> - (ΣX)<sup>2</sup>][NΣY<sup>2</sup> - (ΣY)<sup>2</sup>])]
-- removed inline image ---
newnum = num do 10 i=1,num
if(val1(i) .le. -999.000 .or. val2(i) .le. -999.000 ) then
newnum = newnum - 1
goto 10
endif
sumx = sumx + val1(i)
sumy = sumy + val2(i)
sumxy = sumxy + val1(i)*val2(i)
sumx2 = sumx2 + val1(i)**2
sumy2 = sumy2 + val2(i)**2
10 continue
if(newnum .le. 0) then
type *,' '
type *,'gbicorcoef - newnum = ',newnum
type *,' '
rcode = 2
return
endif
corcoef = newnum*sumxy - sumx*sumy
if((newnum*sumx2-sumx**2)*(<wbr>newnum*sumy2-sumy**2) .le. 0) then
type *,'gbicorcoef - trying sqrt on ',
+ (newnum*sumx2-sumx**2)*(<wbr>newnum*sumy2-sumy**2)
corcoef = -999.999
goto 9999
endif
corcoef =
+ corcoef/sqrt((newnum*sumx2-<wbr>sumx**2)*(newnum*sumy2-sumy**<wbr>2))
Correlation formula: [ NΣXY - (ΣX)(ΣY) / Sqrt([NΣX<sup>2</sup> - (ΣX)<sup>2</sup>][NΣY<sup>2</sup> - (ΣY)<sup>2</sup>])]
-- removed inline image ---