ClearAll;

n = 4;

x = {0.5, 2, 4, 3.25};

y = {1, 2, 3, 2};

xmean = (1/n)*Sum[x[[k]], {k, 1, n}];

ymean = (1/n)*Sum[y[[k]], {k, 1, n}];

sigmaxy = (1/n)*
          Sum[(x[[k]] - xmean) (y[[k]] - ymean), {k, 1, 
              n}];

sigmax = 
        Sqrt[(1/n)*
            Sum[(x[[k]] - xmean)^2, {k, 1, n}]];

sigmay = 
        Sqrt[(1/n)*
            Sum[(y[[k]] - ymean)^2, {k, 1, n}]];

m = N[sigmaxy/sigmax^2]

q = N[ymean - m*xmean]

corr = N[sigmaxy/(sigmax*sigmay)]

p = 
        ListPlot[Table[{x[[i]], y[[i]]}, {i, 1, n}], 
          PlotStyle -> PointSize[0.03], 
          PlotRange -> {0, 3.5}];

g = 
        Plot[m*t + q, {t, Min[x], Max[x]}, 
          PlotRange -> {0, 3.5}];

Show[p, g]