1

I'm working on an application with statistic analysis, and I need some help. Given a set of n points, how can I approximate a line by them. I'm sure there is an algorithm but I couldn't find it.

Thanks!

Alex
  • 737
  • 1
  • 9
  • 19

2 Answers2

3

The topic is called linear regression, or ordinary least squares. You should be able to find more details in any linear algebra or stat book.

A Java implementation can be found here

Charles E. Grant
  • 5,771
  • 1
  • 20
  • 21
1

If you're trying to fit a straight line, I suggest you look at linear regression. This old SO answer handles the more general case of curve fitting in Java and eventually recommends CurveFitting Java.

Community
  • 1
  • 1
Jacob
  • 34,255
  • 14
  • 110
  • 165
  • For fitting curves there's non-linear regression. http://en.wikipedia.org/wiki/Nonlinear_regression http://en.wikipedia.org/wiki/Curve_fitting – Tansir1 Jul 16 '10 at 19:23