I'm just reading the source code of talib, and find some bugs, here is the source code link
http://sourceforge.net/p/ta-lib/code/HEAD/tree/trunk/ta-lib/c/src/ta_func/ta_LINEARREG.c#l247
""One""
for below code in line 247
m = ( optInTimePeriod * SumXY - SumX * SumY) / Divisor;
According to my derivation, I think the right one should be
m = ( SumX * SumY - optInTimePeriod * SumXY) / Divisor;
""Two""
I find the conflict expression between line 245 and 249, for example (optInTimePeriod=3)
Y0 Y1 Y2
0 1 2
line 245 align f(today-i) to m*i+b,which means 0 -> Y2, 1 -> Y1, 2 -> Y0
SumY += tempValue1 = inReal[today - i];
SumXY += (double)i * tempValue1;
but in line 249, we want to calculate Y2, here we use 2 to calculate Y2, which means 2 -> Y2
outReal[outIdx++] = b + m * (double)(optInTimePeriod-1);
so I think line 245 is wrong.
does anyone has same concern here? please feel free to correct me if i'm wrong.