- UID
- 2
- 积分
- 2893117
- 威望
- 1396590 布
- 龙e币
- 1496527 刀
- 在线时间
- 13326 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-26
|
【CoefficientR】
- 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 ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|