PureBytes Links
Trading Reference Links
|
I'm trying to move away from Excel VBA into VB and found that Visual Basic
lacks statistics functions. Therefore, I need to calculate the values from
scratch, but I'm not having any success.
Here's a snippet calculating the slope and y-intercept for the best fit
line in a scatter x-y plot:
For counter = 0 to 199
x = xArray(counter)
y = yArray(counter)
A = x * y 'x*y
B = B + A 'sum of x*y
C = C + x 'sum of x
D = D+ y 'sum of y
E = E + x ^ 2 'sum of x squared
Next counter
Slope = (B* C* D) / E- C^2
Y_intercept = (D*E - C*B) / E - C^2
The slope and Y_intercept are wrong. Would somebody help me?
Thanks,
Craig
|