Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The situation is this: a series of points are randomly located, a line is needed to represent the gradient of those points.

  /  .

. / ./ / .

I am a programmer but not math expert, I need the method to find such a line. Can anyone give me some direction?

Thanks in advance.

share|cite|improve this question

There is a technique called "least squares linear fit." Those keywords should help you find a discussion in a textbook or on the web.

share|cite|improve this answer
Cool, this looks like what I need, thanks a lot! – Truman's world Jan 28 '13 at 13:25
You have the option of "accepting" the answer, by clicking in the check mark next to it. – Gerry Myerson Jan 28 '13 at 22:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.