Skip to content

Instantly share code, notes, and snippets.

@bozhink
Created March 15, 2014 11:48
Show Gist options
  • Save bozhink/9565811 to your computer and use it in GitHub Desktop.
Save bozhink/9565811 to your computer and use it in GitHub Desktop.
Simple linear regression finction for Scilab
function [a,b]=linlsq(X,Y)
[n,m]=size(X);
n=n*m;
sumx = sum(X);
sumy = sum(Y);
sumxx = sum(X.*X);
sumxy = sum(X.*Y);
a=(sumx*sumy-n*sumxy)/(sumx*sumx-n*sumxx);
b=(sumy-a*sumx)/n;
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment