Add regression lines to your revised statistical application (parser + statistical/charting engine).
Code VB.Net
https://drive.google.com/file/d/1TFEmibUFSHRXVqiH9frzuWL0XIIPsjli/view?usp=sharing
To calculate regression line we use:
y = a + bx
Dim x_prec As Double = listOfBDataP(0).x1
Dim y_dipPrec As Double = a + b * x_prec
For Each d In listOfBDataP.Skip(1)
Dim y_dipCurr As Double = a + b * d.x1
Dim p_xPrec As Double = X_Viewport(x_prec, viewport, min_x, range_x)
Dim p_yPrec As Double = Y_Viewport(y_dipPrec, viewport, min_y, range_y)
Dim p_xCurr As Double = X_Viewport(d.x1, viewport, min_x, range_x)
Dim p_yCurr As Double = Y_Viewport(y_dipCurr, viewport, min_y, range_y)
gc.DrawLine(Pens.Red, New Point(p_xPrec, p_yPrec), New Point(p_xCurr, p_yCurr))
x_prec = d.x1
y_dipPrec = y_dipCurr
Next
where
b = COV(X,Y)/variance
a = y – bx
(y and x are the average of Y and X value)
Remember:


Dim sigma = calc_var()
Dim b As Double = Calc_cov() / sigma
Dim a As Double = current_onlineMeanY - b * current_onlineMeanX
Public Function Calc_cov() As Double
Dim sum As Double
Dim n As Double = listOfBDataP.Count
For Each d In listOfBDataP
sum += d.x1 * d.x2
Next
Return (sum - n * current_onlineMeanX * current_onlineMeanY) / (n - 1)
End Function
Public Function Calc_var() As Double
Dim sigma As Double
For Each d In listOfBDataP
sigma += Math.Pow((d.x1 - current_onlineMeanX), 2)
Next
Return sigma / (listOfBDataP.Count - 1)
End Function




https://www.webtutordimatematica.it/materie/statistica-e-probabilita/modelli-di-regressione/regressione-lineare-semplice/calcolo-parametri-retta-regressione