/// <summary> /// Math equation linear : Y = B1*X + B0 /// </summary> public void Solve(out double B0, out double B1) { double xbar = VX.Sum() / VX.Count; double ybar = VY.Sum() / VY.Count; double sumX2 = VX.Sum(t => t * t); double xxbar = 0, yybar = 0, xybar = 0; for (int i = 0; i < VX.Count; i++) { xxbar += (VX[i] - xbar) * (VX[i] - xbar); yybar += (VY[i] - ybar) * (VY[i] - ybar); xybar += (VX[i] - xbar) * (VY[i] - ybar); } B1 = xybar / xxbar; B0 = ybar - B1 * xbar; }