views:

219

answers:

3

Hi,

I am running some calculations in an external machine and at the end I get X, Y pairs. I want to apply linear regression and obtain A, B, and R2. In this machine I can not install anything (it runs Linux) and has basic stuff installed on it, python, bash (of course), etc.

I wonder what would be the best approach to use a script(python, bash, etc) or program (I can compile C and C++) that gives me the linear regression coefficients without the need to add external libraries (numpy, etc)

Thanks

+1  A: 

How about extracting the coeffs into a file, import to another machine and then use Excel/Matlab/whatever other program that does this for you?

villintehaspam
+3  A: 

For a single, simple, known function (as in your case: a line) it is not hard to simply code a basic least square routine from scratch (but does require some attention to detail). It is a very common assignment in introductory numeric analysis classes.

So, look up least squares on wikipedia or mathworld or in a text book and go to town.

dmckee
+1  A: 

There's some pure python code here.

http://www.phys.uu.nl/~haque/computing/WPark_recipes_in_python.html

But why ask here when a google search would have given you the answer in 30 seconds?

Paul Hankin
probably I am hipo-google and can not find so fast the answers like you :)
asdf