codigo que calcule y grafique una regresion lineal

`#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include "gnuplot-iostream.h" using namespace std; double ajuste_lineal(vector<double> x, vector<double> y, int n) { double a, b; double media_x = 0; double media_y = 0; double sum_xy = 0; double sum_x2 = 0; for (int i = 0; i < n; i++) { media_x += x[i]; media_y += y[i]; sum_xy += (x[i] * y[i]); sum_x2 += (x[i] * x[i]); } a = (n * sum_xy - media_x * media_y) / (n * sum_x2 - media_x * media_x); b = (media_y - a * media_x) / n`