【LinRegArray2】
[code]inputs:IndepArray[XSize]( numericarray ),
DepArray[YSize]( numericarray ),
Size( numericsimple ),
TgtPos( numericsimple ),
oLRSlope( numericref ),
oLRAngle( numericref ),
oLRIntercept( numericref ),
oLRValueRaw( numericref ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 0 ),
var5( 0 ) ;
if Size > 1 then
begin
var0 = 0 ;
var1 = 0 ;
var2 = 0 ;
var3 = 0 ;
for var4 = 1 to Size
begin
var0 = var0 + IndepArray[var4] ;
var3 = var3 + Square( IndepArray[var4] ) ;
var1 = var1 + DepArray[var4] ;
var2 = var2 + ( IndepArray[var4] * DepArray[var4] ) ;
end ;
var5 = Square( var0 ) - Size * var3 ;
oLRSlope = ( Size * var2 - var0 * var1) / var5 ;
oLRAngle = ArcTangent( oLRSlope ) ;
oLRIntercept = ( var1 + oLRSlope * var0 ) / Size ;
oLRValueRaw = oLRIntercept + oLRSlope * -TgtPos ;
LinRegArray2 = 1 ;
end
else
LinRegArray2 = -1 ;
[/code]
页:
[1]