【CoefficientR】
[code]inputs:Indep( numericseries ),
Dep( numericseries ),
Len( numericsimple ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 0 ),
var5( 0 ),
var6( 0 ),
var7( 0 ) ;
CoefficientR = -2 ;
if Len > 0 then
begin
var0 = 0 ;
var1 = 0 ;
for Value1 = 0 to Len - 1
begin
var0 = var0 + Indep[Value1] ;
var1 = var1 + Dep[Value1] ;
end ;
var0 = var0 / Len ;
var1 = var1 / Len ;
var4 = 0 ;
var2 = 0 ;
var3 = 0 ;
for Value1 = 0 to Len - 1
begin
var6 = Indep[Value1] - var0 ;
var5 = Dep[Value1] - var1 ;
var4 = var4 + Square( var6 ) ;
var2 = var2 + Square( var5 ) ;
var3 = var3 + var6 * var5 ;
end ;
Value2 = var4 * var2 ;
if Value2 > 0 then
begin
var7 = var3 / SquareRoot( Value2 ) ;
condition1 = var7 >= -1 and var7 <= 1;
if condition1 then
CoefficientR = var7 ;
end ;
end ;
[/code]
页:
[1]